home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / gopher / Unix / gateways / techinfo / techinpher / v1.0.tar < prev   
Tape Archive  |  1994-01-26  |  136.0 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: Tape Archive (archive/tar).

You can browse this item here: v1.0.tar

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Tape Archive (archive/tar) magic Supported
100% file tar archive default
99% file tar archive (V7), file v1.0/, mode 755 , uid 0 , gid 25 , size 0 , seconds 5520334637 default
98% file data default
100% TrID Sybase iAnywhere database files default (weak)
100% lsar Tar default
100% gt2 TAR Archiv gefunden (Auflistung ist deaktiviert) default
100% disktype Pre-POSIX tar archive default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 76 31 2e 30 2f 00 00 00 | 00 00 00 00 00 00 00 00 |v1.0/...|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000060| 00 00 00 00 20 20 20 37 | 35 35 20 00 20 20 20 20 |.... 7|55 . |
|00000070| 20 30 20 00 20 20 20 20 | 32 35 20 00 20 20 20 20 | 0 . |25 . |
|00000080| 20 20 20 20 20 20 30 20 | 20 35 35 32 30 33 33 34 | 0 | 5520334|
|00000090| 36 33 37 20 20 20 34 34 | 34 32 00 20 00 00 00 00 |637 44|42. ....|
|000000a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000120| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000130| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000140| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000150| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000170| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000180| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 76 31 2e 30 2f 73 65 72 | 76 65 72 2e 63 00 00 00 |v1.0/ser|ver.c...|
|00000210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 00 00 00 20 20 20 36 | 34 34 20 00 20 20 20 20 |.... 6|44 . |
|00000270| 20 30 20 00 20 20 20 20 | 32 35 20 00 20 20 20 20 | 0 . |25 . |
|00000280| 20 20 34 33 33 34 33 20 | 20 35 33 34 32 37 33 33 | 43343 | 5342733|
|00000290| 33 35 34 20 20 20 36 32 | 33 31 00 20 00 00 00 00 |354 62|31. ....|
|000002a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000300| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000310| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000320| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000330| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000340| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000350| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000360| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000370| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000380| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000390| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 2f 2a 0a 20 2a 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |/*. *---|--------|
|00000410| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000420| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000430| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000440| 2d 2d 2d 2d 2d 2d 2d 0a | 20 2a 0a 20 2a 20 24 53 |-------.| *. * $S|
|00000450| 6f 75 72 63 65 3a 20 2f | 61 66 73 2f 6e 65 74 2e |ource: /|afs/net.|
|00000460| 6d 69 74 2e 65 64 75 2f | 64 61 70 70 73 2f 70 72 |mit.edu/|dapps/pr|
|00000470| 6f 6a 65 63 74 2f 74 65 | 63 68 69 6e 66 6f 64 65 |oject/te|chinfode|
|00000480| 76 2f 73 72 63 2f 73 72 | 76 5f 74 69 2f 52 43 53 |v/src/sr|v_ti/RCS|
|00000490| 2f 73 65 72 76 65 72 2e | 63 2c 76 20 24 0a 20 2a |/server.|c,v $. *|
|000004a0| 20 24 52 65 76 69 73 69 | 6f 6e 3a 20 31 2e 36 20 | $Revisi|on: 1.6 |
|000004b0| 24 0a 20 2a 20 24 44 61 | 74 65 3a 20 39 32 2f 30 |$. * $Da|te: 92/0|
|000004c0| 38 2f 32 38 20 31 36 3a | 30 39 3a 34 37 20 24 0a |8/28 16:|09:47 $.|
|000004d0| 20 2a 20 24 53 74 61 74 | 65 3a 20 45 78 70 20 24 | * $Stat|e: Exp $|
|000004e0| 0a 20 2a 20 24 41 75 74 | 68 6f 72 3a 20 61 72 6b |. * $Aut|hor: ark|
|000004f0| 20 24 0a 20 2a 20 24 4c | 6f 63 6b 65 72 3a 20 61 | $. * $L|ocker: a|
|00000500| 72 6b 20 24 0a 20 2a 0a | 20 2a 20 24 4c 6f 67 3a |rk $. *.| * $Log:|
|00000510| 09 73 65 72 76 65 72 2e | 63 2c 76 20 24 0a 20 2a |.server.|c,v $. *|
|00000520| 20 52 65 76 69 73 69 6f | 6e 20 31 2e 36 20 20 39 | Revisio|n 1.6 9|
|00000530| 32 2f 30 38 2f 32 38 20 | 20 31 36 3a 30 39 3a 34 |2/08/28 | 16:09:4|
|00000540| 37 20 20 61 72 6b 0a 20 | 2a 20 53 75 6d 6d 65 72 |7 ark. |* Summer|
|00000550| 20 31 39 39 32 20 66 69 | 6e 61 6c 20 76 65 72 73 | 1992 fi|nal vers|
|00000560| 69 6f 6e 0a 20 2a 20 0a | 20 2a 20 52 65 76 69 73 |ion. * .| * Revis|
|00000570| 69 6f 6e 20 31 2e 35 20 | 20 39 32 2f 30 38 2f 31 |ion 1.5 | 92/08/1|
|00000580| 32 20 20 31 34 3a 31 38 | 3a 32 36 20 20 61 72 6b |2 14:18|:26 ark|
|00000590| 0a 20 2a 20 4e 65 77 20 | 76 65 72 73 69 6f 6e 20 |. * New |version |
|000005a0| 6f 66 20 27 6f 27 20 74 | 72 61 6e 73 61 63 74 69 |of 'o' t|ransacti|
|000005b0| 6f 6e 20 74 65 6c 6c 73 | 20 77 68 61 74 20 6f 75 |on tells| what ou|
|000005c0| 74 70 75 74 20 66 6f 72 | 6d 61 74 20 74 6f 20 75 |tput for|mat to u|
|000005d0| 73 65 3b 0a 20 2a 20 74 | 68 69 73 20 69 73 20 61 |se;. * t|his is a|
|000005e0| 20 68 61 63 6b 20 74 6f | 20 61 6c 6c 6f 77 20 6f | hack to| allow o|
|000005f0| 6c 64 20 28 62 75 74 20 | 62 72 6f 6b 65 6e 29 20 |ld (but |broken) |
|00000600| 63 6c 69 65 6e 74 73 20 | 74 6f 20 73 74 69 6c 6c |clients |to still|
|00000610| 20 77 6f 72 6b 2e 0a 20 | 2a 20 0a 20 2a 20 52 65 | work.. |* . * Re|
|00000620| 76 69 73 69 6f 6e 20 31 | 2e 34 20 20 39 32 2f 30 |vision 1|.4 92/0|
|00000630| 38 2f 31 31 20 20 31 33 | 3a 34 36 3a 35 34 20 20 |8/11 13|:46:54 |
|00000640| 61 72 6b 0a 20 2a 20 42 | 75 67 20 66 69 78 65 73 |ark. * B|ug fixes|
|00000650| 3a 20 27 6e 27 20 74 72 | 61 6e 73 61 63 74 69 6f |: 'n' tr|ansactio|
|00000660| 6e 20 6c 65 61 76 69 6e | 67 20 66 69 6c 65 20 64 |n leavin|g file d|
|00000670| 65 73 63 72 69 70 74 6f | 72 73 20 6f 70 65 6e 3b |escripto|rs open;|
|00000680| 0a 20 2a 20 20 20 20 20 | 20 20 20 20 20 20 20 27 |. * | '|
|00000690| 62 27 20 74 72 61 6e 73 | 61 63 74 69 6f 6e 20 6e |b' trans|action n|
|000006a0| 6f 77 20 64 69 73 61 6c | 6c 6f 77 73 20 73 65 61 |ow disal|lows sea|
|000006b0| 72 63 68 65 73 20 6f 6e | 20 65 6d 70 74 79 20 73 |rches on| empty s|
|000006c0| 74 72 69 6e 67 73 2e 0a | 20 2a 20 0a 20 2a 20 52 |trings..| * . * R|
|000006d0| 65 76 69 73 69 6f 6e 20 | 31 2e 33 20 20 39 32 2f |evision |1.3 92/|
|000006e0| 30 38 2f 30 36 20 20 31 | 38 3a 34 34 3a 33 32 20 |08/06 1|8:44:32 |
|000006f0| 20 61 72 6b 0a 20 2a 20 | 41 64 6d 69 6e 20 63 6f | ark. * |Admin co|
|00000700| 6d 6d 61 6e 64 20 22 42 | 22 20 6e 6f 20 6c 6f 6e |mmand "B|" no lon|
|00000710| 67 65 72 20 63 72 61 73 | 68 65 73 20 77 68 65 6e |ger cras|hes when|
|00000720| 20 74 68 65 72 65 20 61 | 72 65 20 6d 61 6e 79 20 | there a|re many |
|00000730| 63 6f 6e 6e 65 63 74 69 | 6f 6e 73 2e 0a 20 2a 20 |connecti|ons.. * |
|00000740| 0a 20 2a 20 52 65 76 69 | 73 69 6f 6e 20 31 2e 32 |. * Revi|sion 1.2|
|00000750| 20 20 39 32 2f 30 38 2f | 30 34 20 20 31 36 3a 32 | 92/08/|04 16:2|
|00000760| 38 3a 31 32 20 20 61 72 | 6b 0a 20 2a 20 54 65 73 |8:12 ar|k. * Tes|
|00000770| 74 20 70 72 6f 64 75 63 | 74 69 6f 6e 20 76 65 72 |t produc|tion ver|
|00000780| 73 69 6f 6e 20 38 2f 34 | 2f 39 32 0a 20 2a 20 0a |sion 8/4|/92. * .|
|00000790| 20 2a 20 52 65 76 69 73 | 69 6f 6e 20 31 2e 31 20 | * Revis|ion 1.1 |
|000007a0| 20 39 32 2f 30 37 2f 32 | 32 20 20 31 31 3a 30 39 | 92/07/2|2 11:09|
|000007b0| 3a 32 39 20 20 61 72 6b | 0a 20 2a 20 53 61 62 65 |:29 ark|. * Sabe|
|000007c0| 72 20 6c 6f 61 64 73 20 | 71 75 69 65 74 6c 79 3b |r loads |quietly;|
|000007d0| 20 41 4e 53 49 20 75 73 | 65 20 73 74 61 6e 64 61 | ANSI us|e standa|
|000007e0| 72 64 69 7a 65 64 3b 20 | 63 6f 6d 6d 61 6e 64 20 |rdized; |command |
|000007f0| 6c 69 6e 65 20 6f 70 74 | 69 6f 6e 73 3b 20 6e 6f |line opt|ions; no|
|00000800| 20 62 65 68 61 76 69 6f | 72 61 6c 20 63 68 61 6e | behavio|ral chan|
|00000810| 67 65 73 0a 20 2a 20 0a | 20 2a 20 52 65 76 69 73 |ges. * .| * Revis|
|00000820| 69 6f 6e 20 31 2e 30 20 | 20 39 32 2f 30 37 2f 31 |ion 1.0 | 92/07/1|
|00000830| 30 20 20 31 32 3a 33 34 | 3a 30 30 20 20 61 72 6b |0 12:34|:00 ark|
|00000840| 0a 20 2a 20 49 6e 69 74 | 69 61 6c 20 72 65 76 69 |. * Init|ial revi|
|00000850| 73 69 6f 6e 0a 20 2a 20 | 0a 20 2a 20 52 65 76 69 |sion. * |. * Revi|
|00000860| 73 69 6f 6e 20 31 2e 31 | 20 20 39 31 2f 30 37 2f |sion 1.1| 91/07/|
|00000870| 31 35 20 20 31 30 3a 34 | 30 3a 33 39 20 20 74 68 |15 10:4|0:39 th|
|00000880| 6f 72 6e 65 0a 20 2a 20 | 49 6e 69 74 69 61 6c 20 |orne. * |Initial |
|00000890| 72 65 76 69 73 69 6f 6e | 0a 20 2a 20 0a 20 2a 2d |revision|. * . *-|
|000008a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008b0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008c0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008d0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000008e0| 2d 0a 20 2a 2f 0a 0a 23 | 69 66 6e 64 65 66 20 6c |-. */..#|ifndef l|
|000008f0| 69 6e 74 0a 23 69 66 6e | 64 65 66 20 53 41 42 45 |int.#ifn|def SABE|
|00000900| 52 0a 73 74 61 74 69 63 | 20 63 68 61 72 20 2a 72 |R.static| char *r|
|00000910| 63 73 69 64 5f 66 6f 6f | 5f 63 20 3d 20 22 24 48 |csid_foo|_c = "$H|
|00000920| 65 61 64 65 72 3a 20 2f | 61 66 73 2f 6e 65 74 2e |eader: /|afs/net.|
|00000930| 6d 69 74 2e 65 64 75 2f | 64 61 70 70 73 2f 70 72 |mit.edu/|dapps/pr|
|00000940| 6f 6a 65 63 74 2f 74 65 | 63 68 69 6e 66 6f 64 65 |oject/te|chinfode|
|00000950| 76 2f 73 72 63 2f 73 72 | 76 5f 74 69 2f 52 43 53 |v/src/sr|v_ti/RCS|
|00000960| 2f 73 65 72 76 65 72 2e | 63 2c 76 20 31 2e 36 20 |/server.|c,v 1.6 |
|00000970| 39 32 2f 30 38 2f 32 38 | 20 31 36 3a 30 39 3a 34 |92/08/28| 16:09:4|
|00000980| 37 20 61 72 6b 20 45 78 | 70 20 4c 6f 63 6b 65 72 |7 ark Ex|p Locker|
|00000990| 3a 20 61 72 6b 20 24 22 | 3b 0a 23 65 6e 64 69 66 |: ark $"|;.#endif|
|000009a0| 0a 23 65 6e 64 69 66 20 | 20 6c 69 6e 74 0a 0a 2f |.#endif | lint../|
|000009b0| 2a 0a 20 2a 20 73 65 72 | 76 65 72 2e 63 20 0a 20 |*. * ser|ver.c . |
|000009c0| 2a 20 53 2e 20 54 68 6f | 72 6e 65 0a 20 2a 20 54 |* S. Tho|rne. * T|
|000009d0| 68 69 73 20 69 73 20 74 | 68 65 20 65 6e 74 72 79 |his is t|he entry|
|000009e0| 20 70 6f 69 6e 74 20 6f | 66 20 74 68 65 20 54 65 | point o|f the Te|
|000009f0| 63 68 69 6e 66 6f 20 73 | 65 72 76 65 72 2e 20 49 |chinfo s|erver. I|
|00000a00| 74 20 6c 6f 61 64 73 20 | 74 68 65 20 77 65 62 20 |t loads |the web |
|00000a10| 61 6e 64 20 67 65 74 73 | 0a 20 2a 20 63 6f 6e 6e |and gets|. * conn|
|00000a20| 65 63 74 69 6f 6e 73 2e | 20 49 74 20 63 6f 6e 74 |ections.| It cont|
|00000a30| 61 69 6e 73 20 74 68 65 | 20 6d 61 69 6e 20 73 65 |ains the| main se|
|00000a40| 72 76 65 72 20 6c 6f 6f | 70 2e 0a 20 2a 2f 0a 2f |rver loo|p.. */./|
|00000a50| 2a 0a 20 20 43 6f 70 79 | 72 69 67 68 74 20 28 43 |*. Copy|right (C|
|00000a60| 29 20 31 39 38 39 20 62 | 79 20 74 68 65 20 4d 61 |) 1989 b|y the Ma|
|00000a70| 73 73 61 63 68 75 73 65 | 74 74 73 20 49 6e 73 74 |ssachuse|tts Inst|
|00000a80| 69 74 75 74 65 20 6f 66 | 20 54 65 63 68 6e 6f 6c |itute of| Technol|
|00000a90| 6f 67 79 0a 0a 20 20 20 | 45 78 70 6f 72 74 20 6f |ogy.. |Export o|
|00000aa0| 66 20 74 68 69 73 20 73 | 6f 66 74 77 61 72 65 20 |f this s|oftware |
|00000ab0| 66 72 6f 6d 20 74 68 65 | 20 55 6e 69 74 65 64 20 |from the| United |
|00000ac0| 53 74 61 74 65 73 20 6f | 66 20 41 6d 65 72 69 63 |States o|f Americ|
|00000ad0| 61 20 69 73 20 61 73 73 | 75 6d 65 64 0a 20 20 20 |a is ass|umed. |
|00000ae0| 74 6f 20 72 65 71 75 69 | 72 65 20 61 20 73 70 65 |to requi|re a spe|
|00000af0| 63 69 66 69 63 20 6c 69 | 63 65 6e 73 65 20 66 72 |cific li|cense fr|
|00000b00| 6f 6d 20 74 68 65 20 55 | 6e 69 74 65 64 20 53 74 |om the U|nited St|
|00000b10| 61 74 65 73 20 47 6f 76 | 65 72 6e 6d 65 6e 74 2e |ates Gov|ernment.|
|00000b20| 0a 20 20 20 49 74 20 69 | 73 20 74 68 65 20 72 65 |. It i|s the re|
|00000b30| 73 70 6f 6e 73 69 62 69 | 6c 69 74 79 20 6f 66 20 |sponsibi|lity of |
|00000b40| 61 6e 79 20 70 65 72 73 | 6f 6e 20 6f 72 20 6f 72 |any pers|on or or|
|00000b50| 67 61 6e 69 7a 61 74 69 | 6f 6e 20 63 6f 6e 74 65 |ganizati|on conte|
|00000b60| 6d 70 6c 61 74 69 6e 67 | 0a 20 20 20 65 78 70 6f |mplating|. expo|
|00000b70| 72 74 20 74 6f 20 6f 62 | 74 61 69 6e 20 73 75 63 |rt to ob|tain suc|
|00000b80| 68 20 61 20 6c 69 63 65 | 6e 73 65 20 62 65 66 6f |h a lice|nse befo|
|00000b90| 72 65 20 65 78 70 6f 72 | 74 69 6e 67 2e 0a 0a 57 |re expor|ting...W|
|00000ba0| 49 54 48 49 4e 20 54 48 | 41 54 20 43 4f 4e 53 54 |ITHIN TH|AT CONST|
|00000bb0| 52 41 49 4e 54 2c 20 70 | 65 72 6d 69 73 73 69 6f |RAINT, p|ermissio|
|00000bc0| 6e 20 74 6f 20 75 73 65 | 2c 20 63 6f 70 79 2c 20 |n to use|, copy, |
|00000bd0| 6d 6f 64 69 66 79 2c 20 | 61 6e 64 0a 64 69 73 74 |modify, |and.dist|
|00000be0| 72 69 62 75 74 65 20 74 | 68 69 73 20 73 6f 66 74 |ribute t|his soft|
|00000bf0| 77 61 72 65 20 61 6e 64 | 20 69 74 73 20 64 6f 63 |ware and| its doc|
|00000c00| 75 6d 65 6e 74 61 74 69 | 6f 6e 20 66 6f 72 20 61 |umentati|on for a|
|00000c10| 6e 79 20 70 75 72 70 6f | 73 65 20 61 6e 64 0a 77 |ny purpo|se and.w|
|00000c20| 69 74 68 6f 75 74 20 66 | 65 65 20 69 73 20 68 65 |ithout f|ee is he|
|00000c30| 72 65 62 79 20 67 72 61 | 6e 74 65 64 2c 20 70 72 |reby gra|nted, pr|
|00000c40| 6f 76 69 64 65 64 20 74 | 68 61 74 20 74 68 65 20 |ovided t|hat the |
|00000c50| 61 62 6f 76 65 20 63 6f | 70 79 72 69 67 68 74 0a |above co|pyright.|
|00000c60| 6e 6f 74 69 63 65 20 61 | 70 70 65 61 72 20 69 6e |notice a|ppear in|
|00000c70| 20 61 6c 6c 20 63 6f 70 | 69 65 73 20 61 6e 64 20 | all cop|ies and |
|00000c80| 74 68 61 74 20 62 6f 74 | 68 20 74 68 61 74 20 63 |that bot|h that c|
|00000c90| 6f 70 79 72 69 67 68 74 | 20 6e 6f 74 69 63 65 20 |opyright| notice |
|00000ca0| 61 6e 64 0a 74 68 69 73 | 20 70 65 72 6d 69 73 73 |and.this| permiss|
|00000cb0| 69 6f 6e 20 6e 6f 74 69 | 63 65 20 61 70 70 65 61 |ion noti|ce appea|
|00000cc0| 72 20 69 6e 20 73 75 70 | 70 6f 72 74 69 6e 67 20 |r in sup|porting |
|00000cd0| 64 6f 63 75 6d 65 6e 74 | 61 74 69 6f 6e 2c 20 61 |document|ation, a|
|00000ce0| 6e 64 20 74 68 61 74 0a | 74 68 65 20 6e 61 6d 65 |nd that.|the name|
|00000cf0| 20 6f 66 20 4d 2e 49 2e | 54 2e 20 6e 6f 74 20 62 | of M.I.|T. not b|
|00000d00| 65 20 75 73 65 64 20 69 | 6e 20 61 64 76 65 72 74 |e used i|n advert|
|00000d10| 69 73 69 6e 67 20 6f 72 | 20 70 75 62 6c 69 63 69 |ising or| publici|
|00000d20| 74 79 20 70 65 72 74 61 | 69 6e 69 6e 67 0a 74 6f |ty perta|ining.to|
|00000d30| 20 64 69 73 74 72 69 62 | 75 74 69 6f 6e 20 6f 66 | distrib|ution of|
|00000d40| 20 74 68 65 20 73 6f 66 | 74 77 61 72 65 20 77 69 | the sof|tware wi|
|00000d50| 74 68 6f 75 74 20 73 70 | 65 63 69 66 69 63 2c 20 |thout sp|ecific, |
|00000d60| 77 72 69 74 74 65 6e 20 | 70 72 69 6f 72 0a 70 65 |written |prior.pe|
|00000d70| 72 6d 69 73 73 69 6f 6e | 2e 20 20 4d 2e 49 2e 54 |rmission|. M.I.T|
|00000d80| 2e 20 6d 61 6b 65 73 20 | 6e 6f 20 72 65 70 72 65 |. makes |no repre|
|00000d90| 73 65 6e 74 61 74 69 6f | 6e 73 20 61 62 6f 75 74 |sentatio|ns about|
|00000da0| 20 74 68 65 20 73 75 69 | 74 61 62 69 6c 69 74 79 | the sui|tability|
|00000db0| 20 6f 66 0a 74 68 69 73 | 20 73 6f 66 74 77 61 72 | of.this| softwar|
|00000dc0| 65 20 66 6f 72 20 61 6e | 79 20 70 75 72 70 6f 73 |e for an|y purpos|
|00000dd0| 65 2e 20 20 49 74 20 69 | 73 20 70 72 6f 76 69 64 |e. It i|s provid|
|00000de0| 65 64 20 22 61 73 20 69 | 73 22 20 77 69 74 68 6f |ed "as i|s" witho|
|00000df0| 75 74 20 65 78 70 72 65 | 73 73 0a 6f 72 20 69 6d |ut expre|ss.or im|
|00000e00| 70 6c 69 65 64 20 77 61 | 72 72 61 6e 74 79 2e 0a |plied wa|rranty..|
|00000e10| 0a 2a 2f 0a 0a 23 69 6e | 63 6c 75 64 65 20 3c 73 |.*/..#in|clude <s|
|00000e20| 74 64 69 6f 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |tdio.h>.|#include|
|00000e30| 20 3c 65 72 72 6e 6f 2e | 68 3e 0a 23 69 6e 63 6c | <errno.|h>.#incl|
|00000e40| 75 64 65 20 3c 73 79 73 | 2f 74 79 70 65 73 2e 68 |ude <sys|/types.h|
|00000e50| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 79 73 2f |>.#inclu|de <sys/|
|00000e60| 74 69 6d 65 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |time.h>.|#include|
|00000e70| 20 3c 73 79 73 2f 66 69 | 6c 65 2e 68 3e 0a 23 69 | <sys/fi|le.h>.#i|
|00000e80| 6e 63 6c 75 64 65 20 3c | 73 69 67 6e 61 6c 2e 68 |nclude <|signal.h|
|00000e90| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 72 69 |>.#inclu|de <stri|
|00000ea0| 6e 67 73 2e 68 3e 0a 23 | 69 6e 63 6c 75 64 65 20 |ngs.h>.#|include |
|00000eb0| 22 6e 65 74 77 6f 72 6b | 2e 68 22 0a 23 69 6e 63 |"network|.h".#inc|
|00000ec0| 6c 75 64 65 20 22 69 6e | 65 74 2e 68 22 0a 2f 2a |lude "in|et.h"./*|
|00000ed0| 23 69 6e 63 6c 75 64 65 | 20 22 77 65 62 2e 68 22 |#include| "web.h"|
|00000ee0| 20 2a 2f 0a 23 69 6e 63 | 6c 75 64 65 20 22 70 64 | */.#inc|lude "pd|
|00000ef0| 62 2e 68 22 20 20 0a 2f | 2a 20 23 69 6e 63 6c 75 |b.h" ./|* #inclu|
|00000f00| 64 65 20 3c 75 6e 69 73 | 74 64 2e 68 3e 20 20 55 |de <unis|td.h> U|
|00000f10| 6c 72 69 69 78 20 3f 3f | 3f 20 2a 2f 0a 0a 43 4f |lriix ??|? */..CO|
|00000f20| 4e 4e 20 20 20 20 20 20 | 20 20 20 20 20 20 63 6f |NN | co|
|00000f30| 6e 6e 74 61 62 5b 46 44 | 5f 53 45 54 53 49 5a 45 |nntab[FD|_SETSIZE|
|00000f40| 5d 3b 0a 0a 66 64 5f 73 | 65 74 20 20 20 72 65 61 |];..fd_s|et rea|
|00000f50| 64 5f 66 64 73 3b 0a 66 | 64 5f 73 65 74 20 20 20 |d_fds;.f|d_set |
|00000f60| 77 72 69 74 65 5f 66 64 | 73 3b 0a 66 64 5f 73 65 |write_fd|s;.fd_se|
|00000f70| 74 20 20 20 65 78 63 65 | 70 74 5f 66 64 73 3b 0a |t exce|pt_fds;.|
|00000f80| 0a 23 64 65 66 69 6e 65 | 09 73 6f 63 6b 5f 72 65 |.#define|.sock_re|
|00000f90| 61 64 61 62 6c 65 28 73 | 29 09 46 44 5f 49 53 53 |adable(s|).FD_ISS|
|00000fa0| 45 54 28 73 2c 20 26 72 | 65 61 64 5f 66 64 73 29 |ET(s, &r|ead_fds)|
|00000fb0| 0a 0a 23 64 65 66 69 6e | 65 09 63 6f 6e 6e 5f 77 |..#defin|e.conn_w|
|00000fc0| 72 69 74 65 61 62 6c 65 | 28 63 6e 29 09 46 44 5f |riteable|(cn).FD_|
|00000fd0| 49 53 53 45 54 28 63 6f | 6e 6e 74 61 62 5b 63 6e |ISSET(co|nntab[cn|
|00000fe0| 5d 2e 63 5f 73 6f 63 6b | 65 74 2c 26 77 72 69 74 |].c_sock|et,&writ|
|00000ff0| 65 5f 66 64 73 29 0a 23 | 64 65 66 69 6e 65 09 63 |e_fds).#|define.c|
|00001000| 6f 6e 6e 5f 65 78 63 65 | 70 74 28 63 6e 29 09 20 |onn_exce|pt(cn). |
|00001010| 20 20 20 20 20 20 20 46 | 44 5f 49 53 53 45 54 28 | F|D_ISSET(|
|00001020| 63 6f 6e 6e 74 61 62 5b | 63 6e 5d 2e 63 5f 73 6f |conntab[|cn].c_so|
|00001030| 63 6b 65 74 2c 26 65 78 | 63 65 70 74 5f 66 64 73 |cket,&ex|cept_fds|
|00001040| 29 0a 23 64 65 66 69 6e | 65 09 63 6f 6e 6e 5f 72 |).#defin|e.conn_r|
|00001050| 65 61 64 61 62 6c 65 28 | 63 6e 29 09 73 6f 63 6b |eadable(|cn).sock|
|00001060| 5f 72 65 61 64 61 62 6c | 65 28 63 6f 6e 6e 74 61 |_readabl|e(connta|
|00001070| 62 5b 63 6e 5d 2e 63 5f | 73 6f 63 6b 65 74 29 0a |b[cn].c_|socket).|
|00001080| 23 64 65 66 69 6e 65 09 | 63 6f 6e 6e 5f 65 73 74 |#define.|conn_est|
|00001090| 61 62 6c 69 73 68 65 64 | 28 63 6e 29 09 28 63 6f |ablished|(cn).(co|
|000010a0| 6e 6e 74 61 62 5b 63 6e | 5d 2e 63 5f 73 6f 63 6b |nntab[cn|].c_sock|
|000010b0| 65 74 20 21 3d 20 2d 31 | 29 0a 23 64 65 66 69 6e |et != -1|).#defin|
|000010c0| 65 20 63 6f 6e 6e 5f 77 | 61 69 74 5f 77 72 69 74 |e conn_w|ait_writ|
|000010d0| 65 28 63 6e 29 20 20 20 | 20 20 20 28 63 6f 6e 6e |e(cn) | (conn|
|000010e0| 74 61 62 5b 63 6e 5d 2e | 63 5f 70 74 72 29 20 2f |tab[cn].|c_ptr) /|
|000010f0| 2a 20 69 73 20 74 68 65 | 20 63 6f 6e 6e 65 63 74 |* is the| connect|
|00001100| 69 6f 6e 20 0a 09 09 09 | 09 09 09 09 77 61 69 74 |ion ....|....wait|
|00001110| 69 6e 67 20 66 6f 72 20 | 64 61 74 61 3f 20 2a 2f |ing for |data? */|
|00001120| 0a 23 64 65 66 69 6e 65 | 20 63 6f 6e 6e 5f 77 61 |.#define| conn_wa|
|00001130| 69 74 5f 72 65 63 76 28 | 63 6e 29 20 20 20 20 20 |it_recv(|cn) |
|00001140| 20 28 63 6f 6e 6e 74 61 | 62 5b 63 6e 5d 2e 63 5f | (connta|b[cn].c_|
|00001150| 72 65 63 70 74 72 29 20 | 2f 2a 20 69 73 20 74 68 |recptr) |/* is th|
|00001160| 65 20 63 6f 6e 6e 65 63 | 74 69 6f 6e 20 0a 09 09 |e connec|tion ...|
|00001170| 09 09 09 09 09 73 65 6e | 64 69 6e 67 20 61 20 66 |.....sen|ding a f|
|00001180| 69 6c 65 20 6f 76 65 72 | 3f 20 2a 2f 0a 23 64 65 |ile over|? */.#de|
|00001190| 66 69 6e 65 09 63 6f 6e | 6e 5f 74 69 6d 65 64 6f |fine.con|n_timedo|
|000011a0| 75 74 28 63 6e 29 09 28 | 63 6f 6e 6e 74 61 62 5b |ut(cn).(|conntab[|
|000011b0| 63 6e 5d 2e 63 5f 66 6c | 61 67 73 20 26 20 43 5f |cn].c_fl|ags & C_|
|000011c0| 54 49 4d 45 4f 55 54 29 | 20 0a 23 64 65 66 69 6e |TIMEOUT)| .#defin|
|000011d0| 65 09 63 6f 6e 6e 5f 70 | 72 6f 76 69 64 65 72 28 |e.conn_p|rovider(|
|000011e0| 63 6e 29 09 28 63 6f 6e | 6e 74 61 62 5b 63 6e 5d |cn).(con|ntab[cn]|
|000011f0| 2e 63 5f 66 6c 61 67 73 | 20 26 20 43 5f 50 52 4f |.c_flags| & C_PRO|
|00001200| 56 49 44 45 52 29 20 0a | 0a 23 64 65 66 69 6e 65 |VIDER) .|.#define|
|00001210| 09 50 4f 4c 4c 09 26 74 | 76 0a 23 64 65 66 69 6e |.POLL.&t|v.#defin|
|00001220| 65 20 42 4c 4f 43 4b 09 | 30 0a 0a 23 64 65 66 69 |e BLOCK.|0..#defi|
|00001230| 6e 65 20 41 44 41 59 20 | 38 36 34 30 30 20 20 2f |ne ADAY |86400 /|
|00001240| 2a 20 74 68 69 73 20 73 | 68 6f 75 6c 64 20 67 6f |* this s|hould go|
|00001250| 20 69 6e 20 61 20 2e 68 | 20 66 69 6c 65 2c 20 62 | in a .h| file, b|
|00001260| 75 74 20 77 68 69 63 68 | 3f 20 2d 2d 20 6c 61 6d |ut which|? -- lam|
|00001270| 20 2a 2f 0a 0a 73 74 61 | 74 69 63 20 69 6e 74 20 | */..sta|tic int |
|00001280| 20 20 20 20 20 6e 75 6d | 5f 63 6f 6e 6e 65 63 74 | num|_connect|
|00001290| 69 6f 6e 3b 0a 73 74 61 | 74 69 63 20 69 6e 74 20 |ion;.sta|tic int |
|000012a0| 20 20 20 20 20 6c 69 73 | 74 65 6e 5f 73 6f 63 6b | lis|ten_sock|
|000012b0| 3b 0a 69 6e 74 20 20 20 | 20 20 20 20 20 20 20 20 |;.int | |
|000012c0| 20 20 50 45 4e 44 49 4e | 47 5f 53 48 55 54 44 4f | PENDIN|G_SHUTDO|
|000012d0| 57 4e 20 20 3d 20 46 41 | 4c 53 45 3b 0a 69 6e 74 |WN = FA|LSE;.int|
|000012e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 41 4c 54 | | ALT|
|000012f0| 5f 42 41 4e 4e 45 52 20 | 3d 20 46 41 4c 53 45 3b |_BANNER |= FALSE;|
|00001300| 0a 63 68 61 72 20 20 20 | 20 20 20 20 20 20 20 20 |.char | |
|00001310| 20 2a 73 68 75 74 64 6f | 77 6e 5f 6d 73 67 3b 0a | *shutdo|wn_msg;.|
|00001320| 63 68 61 72 20 20 20 20 | 20 20 20 20 20 20 20 20 |char | |
|00001330| 2a 61 6c 74 5f 62 61 6e | 6e 65 72 3b 0a 73 68 6f |*alt_ban|ner;.sho|
|00001340| 72 74 20 20 20 20 20 20 | 20 20 20 20 20 74 6f 64 |rt | tod|
|00001350| 61 79 73 64 61 74 65 20 | 3d 20 30 3b 20 20 2f 2a |aysdate |= 0; /*|
|00001360| 20 77 69 6c 6c 20 62 65 | 20 70 72 6f 70 65 72 6c | will be| properl|
|00001370| 79 20 69 6e 69 74 69 61 | 6c 69 7a 65 64 20 6c 61 |y initia|lized la|
|00001380| 74 65 72 20 2a 2f 0a 73 | 74 61 74 69 63 20 69 6e |ter */.s|tatic in|
|00001390| 74 20 20 20 20 20 20 61 | 6c 61 72 6d 77 65 6e 74 |t a|larmwent|
|000013a0| 6f 66 66 3b 0a 0a 65 78 | 74 65 72 6e 20 69 6e 74 |off;..ex|tern int|
|000013b0| 20 20 64 61 74 61 73 74 | 72 75 63 74 5f 6c 6f 61 | datast|ruct_loa|
|000013c0| 64 28 69 6e 74 20 75 6e | 6c 6f 61 64 66 69 72 73 |d(int un|loadfirs|
|000013d0| 74 29 3b 0a 65 78 74 65 | 72 6e 20 76 6f 69 64 20 |t);.exte|rn void |
|000013e0| 73 61 76 65 5f 64 61 74 | 61 73 74 72 75 63 74 28 |save_dat|astruct(|
|000013f0| 76 6f 69 64 29 3b 0a 65 | 78 74 65 72 6e 20 76 6f |void);.e|xtern vo|
|00001400| 69 64 20 72 65 6d 6f 76 | 65 5f 73 65 6e 64 28 54 |id remov|e_send(T|
|00001410| 4f 53 45 4e 44 20 2a 70 | 74 72 29 3b 0a 65 78 74 |OSEND *p|tr);.ext|
|00001420| 65 72 6e 20 76 6f 69 64 | 20 72 65 6d 6f 76 65 5f |ern void| remove_|
|00001430| 72 65 63 28 54 4f 52 45 | 43 20 2a 70 74 72 29 3b |rec(TORE|C *ptr);|
|00001440| 0a 65 78 74 65 72 6e 20 | 76 6f 69 64 20 72 65 6d |.extern |void rem|
|00001450| 6f 76 65 5f 68 65 6c 70 | 65 72 28 57 41 49 54 46 |ove_help|er(WAITF|
|00001460| 4f 52 48 45 4c 50 45 52 | 20 2a 70 74 72 29 3b 0a |ORHELPER| *ptr);.|
|00001470| 65 78 74 65 72 6e 20 76 | 6f 69 64 20 6c 6f 67 5f |extern v|oid log_|
|00001480| 74 72 61 6e 73 28 63 68 | 61 72 20 2a 73 74 72 29 |trans(ch|ar *str)|
|00001490| 3b 0a 65 78 74 65 72 6e | 20 76 6f 69 64 20 6e 69 |;.extern| void ni|
|000014a0| 6f 5f 72 65 63 5f 6d 6f | 72 65 28 54 4f 52 45 43 |o_rec_mo|re(TOREC|
|000014b0| 20 2a 70 74 72 29 3b 20 | 0a 65 78 74 65 72 6e 20 | *ptr); |.extern |
|000014c0| 76 6f 69 64 20 63 61 74 | 63 68 5f 63 68 69 6c 64 |void cat|ch_child|
|000014d0| 28 76 6f 69 64 29 3b 0a | 65 78 74 65 72 6e 20 76 |(void);.|extern v|
|000014e0| 6f 69 64 20 63 61 74 63 | 68 5f 68 75 70 28 76 6f |oid catc|h_hup(vo|
|000014f0| 69 64 29 3b 0a 0a 65 78 | 74 65 72 6e 20 69 6e 74 |id);..ex|tern int|
|00001500| 20 20 20 20 20 20 50 52 | 4f 56 3b 20 2f 2a 20 74 | PR|OV; /* t|
|00001510| 68 65 20 73 6f 63 6b 65 | 74 20 23 20 6f 66 20 74 |he socke|t # of t|
|00001520| 68 65 20 63 75 72 72 65 | 6e 74 20 70 72 6f 76 69 |he curre|nt provi|
|00001530| 64 65 72 20 2a 2f 0a 63 | 68 61 72 20 2a 6d 73 67 |der */.c|har *msg|
|00001540| 6c 69 73 74 5b 31 30 30 | 5d 3b 0a 69 6e 74 09 64 |list[100|];.int.d|
|00001550| 65 62 75 67 20 3d 20 30 | 3b 20 2f 2a 20 6e 6f 20 |ebug = 0|; /* no |
|00001560| 64 65 62 75 67 67 69 6e | 67 20 69 73 20 64 65 66 |debuggin|g is def|
|00001570| 61 75 6c 74 20 2a 2f 0a | 0a 0a 76 6f 69 64 20 63 |ault */.|..void c|
|00001580| 61 74 63 68 5f 61 6c 61 | 72 6d 28 76 6f 69 64 29 |atch_ala|rm(void)|
|00001590| 0a 7b 0a 20 20 61 6c 61 | 72 6d 77 65 6e 74 6f 66 |.{. ala|rmwentof|
|000015a0| 66 20 3d 20 31 3b 0a 7d | 0a 0a 0a 0a 2f 2a 20 6c |f = 1;.}|..../* l|
|000015b0| 6f 61 64 20 74 68 65 20 | 66 69 6c 65 20 6f 66 20 |oad the |file of |
|000015c0| 65 72 72 6f 72 20 6d 65 | 73 73 61 67 65 73 2e 20 |error me|ssages. |
|000015d0| 65 72 72 6f 72 20 66 69 | 6c 65 20 68 61 73 20 73 |error fi|le has s|
|000015e0| 74 72 75 63 74 75 72 65 | 20 6f 66 0a 20 20 20 3c |tructure| of. <|
|000015f0| 65 72 72 6f 72 20 23 3e | 3a 3c 65 72 72 6f 72 20 |error #>|:<error |
|00001600| 74 65 78 74 3e 20 2a 2f | 0a 69 6e 74 0a 6c 6f 61 |text> */|.int.loa|
|00001610| 64 5f 6d 73 67 73 28 76 | 6f 69 64 29 20 0a 7b 0a |d_msgs(v|oid) .{.|
|00001620| 0a 09 46 49 4c 45 20 20 | 20 20 20 20 20 20 20 20 |..FILE | |
|00001630| 20 2a 66 6f 70 65 6e 28 | 29 2c 20 2a 6d 73 67 66 | *fopen(|), *msgf|
|00001640| 69 6c 65 3b 0a 20 20 20 | 20 20 20 20 20 63 68 61 |ile;. | cha|
|00001650| 72 20 20 20 20 20 20 6d | 73 67 6c 69 6e 65 5b 31 |r m|sgline[1|
|00001660| 30 31 5d 3b 0a 20 20 20 | 20 20 20 20 20 69 6e 74 |01];. | int|
|00001670| 20 70 6f 73 20 3d 20 30 | 3b 0a 20 20 20 20 20 20 | pos = 0|;. |
|00001680| 20 20 69 6e 74 20 6c 65 | 6e 3b 0a 0a 09 6d 73 67 | int le|n;...msg|
|00001690| 66 69 6c 65 20 3d 20 66 | 6f 70 65 6e 28 4d 53 47 |file = f|open(MSG|
|000016a0| 5f 46 49 4c 45 2c 20 22 | 72 22 29 3b 0a 09 69 66 |_FILE, "|r");..if|
|000016b0| 20 28 21 6d 73 67 66 69 | 6c 65 29 20 7b 0a 09 09 | (!msgfi|le) {...|
|000016c0| 70 65 72 72 6f 72 28 4d | 53 47 5f 46 49 4c 45 29 |perror(M|SG_FILE)|
|000016d0| 3b 0a 09 09 70 75 74 73 | 28 22 43 6f 75 6c 64 20 |;...puts|("Could |
|000016e0| 6e 6f 74 20 66 69 6e 64 | 20 74 68 65 20 6d 65 73 |not find| the mes|
|000016f0| 73 61 67 65 20 66 69 6c | 65 22 29 3b 0a 09 09 65 |sage fil|e");...e|
|00001700| 78 69 74 28 31 29 3b 0a | 09 7d 0a 09 77 68 69 6c |xit(1);.|.}..whil|
|00001710| 65 20 28 66 67 65 74 73 | 28 6d 73 67 6c 69 6e 65 |e (fgets|(msgline|
|00001720| 2c 20 31 30 30 2c 20 6d | 73 67 66 69 6c 65 29 20 |, 100, m|sgfile) |
|00001730| 21 3d 20 27 5c 30 27 29 | 20 7b 0a 09 20 20 6c 65 |!= '\0')| {.. le|
|00001740| 6e 20 3d 20 73 74 72 6c | 65 6e 28 6d 73 67 6c 69 |n = strl|en(msgli|
|00001750| 6e 65 29 3b 0a 09 20 20 | 6d 73 67 6c 69 6e 65 5b |ne);.. |msgline[|
|00001760| 6c 65 6e 20 2d 20 31 5d | 20 3d 20 27 5c 30 27 3b |len - 1]| = '\0';|
|00001770| 0a 09 20 20 6d 73 67 6c | 69 73 74 5b 70 6f 73 5d |.. msgl|ist[pos]|
|00001780| 20 3d 20 28 63 68 61 72 | 20 2a 29 20 64 6f 6d 61 | = (char| *) doma|
|00001790| 6c 6c 6f 63 28 28 75 6e | 73 69 67 6e 65 64 20 69 |lloc((un|signed i|
|000017a0| 6e 74 29 20 6c 65 6e 29 | 3b 0a 09 20 20 73 74 72 |nt) len)|;.. str|
|000017b0| 63 70 79 28 6d 73 67 6c | 69 73 74 5b 70 6f 73 5d |cpy(msgl|ist[pos]|
|000017c0| 2c 6d 73 67 6c 69 6e 65 | 29 3b 0a 09 20 20 70 6f |,msgline|);.. po|
|000017d0| 73 2b 2b 3b 0a 09 7d 0a | 09 66 63 6c 6f 73 65 28 |s++;..}.|.fclose(|
|000017e0| 6d 73 67 66 69 6c 65 29 | 3b 0a 09 72 65 74 75 72 |msgfile)|;..retur|
|000017f0| 6e 20 30 3b 09 09 2f 2a | 20 63 6c 6f 73 65 20 66 |n 0;../*| close f|
|00001800| 69 6c 65 20 2a 2f 0a 0a | 7d 0a 0a 2f 2a 20 77 72 |ile */..|}../* wr|
|00001810| 69 74 65 20 74 68 65 20 | 74 72 61 6e 73 61 63 74 |ite the |transact|
|00001820| 69 6f 6e 20 74 6f 20 74 | 68 65 20 6c 6f 67 20 66 |ion to t|he log f|
|00001830| 69 6c 65 20 2a 2f 0a 76 | 6f 69 64 0a 6c 6f 67 5f |ile */.v|oid.log_|
|00001840| 73 65 73 73 69 6f 6e 28 | 63 68 61 72 20 2a 6c 69 |session(|char *li|
|00001850| 6e 65 29 09 09 20 20 20 | 20 0a 7b 0a 09 69 6e 74 |ne).. | .{..int|
|00001860| 20 64 66 64 3b 0a 09 69 | 66 20 28 28 64 66 64 20 | dfd;..i|f ((dfd |
|00001870| 3d 20 6f 70 65 6e 28 4c | 4f 47 5f 46 49 4c 45 2c |= open(L|OG_FILE,|
|00001880| 20 4f 5f 41 50 50 45 4e | 44 20 7c 20 4f 5f 43 52 | O_APPEN|D | O_CR|
|00001890| 45 41 54 20 7c 20 4f 5f | 57 52 4f 4e 4c 59 2c 20 |EAT | O_|WRONLY, |
|000018a0| 30 36 34 34 29 29 20 3d | 3d 20 30 29 0a 09 09 70 |0644)) =|= 0)...p|
|000018b0| 72 69 6e 74 66 28 22 65 | 72 72 6f 72 20 6c 6f 67 |rintf("e|rror log|
|000018c0| 67 69 6e 67 20 74 72 61 | 6e 73 61 63 74 69 6f 6e |ging tra|nsaction|
|000018d0| 5c 6e 22 29 3b 0a 09 77 | 72 69 74 65 28 64 66 64 |\n");..w|rite(dfd|
|000018e0| 2c 20 6c 69 6e 65 2c 20 | 73 74 72 6c 65 6e 28 6c |, line, |strlen(l|
|000018f0| 69 6e 65 29 29 3b 0a 09 | 63 6c 6f 73 65 28 64 66 |ine));..|close(df|
|00001900| 64 29 3b 0a 09 72 65 74 | 75 72 6e 3b 0a 7d 0a 0a |d);..ret|urn;.}..|
|00001910| 76 6f 69 64 0a 64 75 6d | 70 5f 63 6f 6e 6e 74 61 |void.dum|p_connta|
|00001920| 62 28 76 6f 69 64 29 0a | 7b 0a 20 20 69 6e 74 20 |b(void).|{. int |
|00001930| 69 2c 66 64 3b 0a 20 20 | 63 68 61 72 20 6c 69 6e |i,fd;. |char lin|
|00001940| 65 5b 32 30 30 5d 3b 0a | 20 20 0a 20 20 66 64 20 |e[200];.| . fd |
|00001950| 3d 20 6f 70 65 6e 28 22 | 63 6f 6e 6e 74 61 62 22 |= open("|conntab"|
|00001960| 2c 4f 5f 43 52 45 41 54 | 7c 4f 5f 54 52 55 4e 43 |,O_CREAT||O_TRUNC|
|00001970| 7c 4f 5f 57 52 4f 4e 4c | 59 2c 20 30 36 34 34 29 ||O_WRONL|Y, 0644)|
|00001980| 3b 0a 20 20 66 6f 72 20 | 28 69 20 3d 20 30 3b 20 |;. for |(i = 0; |
|00001990| 69 20 3c 20 46 44 5f 53 | 45 54 53 49 5a 45 3b 20 |i < FD_S|ETSIZE; |
|000019a0| 69 2b 2b 29 20 7b 0a 20 | 20 20 20 69 66 20 28 63 |i++) {. | if (c|
|000019b0| 6f 6e 6e 5f 65 73 74 61 | 62 6c 69 73 68 65 64 28 |onn_esta|blished(|
|000019c0| 69 29 29 7b 0a 20 20 20 | 20 20 20 73 70 72 69 6e |i)){. | sprin|
|000019d0| 74 66 28 6c 69 6e 65 2c | 22 63 6f 6e 6e 20 23 20 |tf(line,|"conn # |
|000019e0| 25 64 2c 20 73 6f 63 6b | 20 3d 20 25 64 2c 20 68 |%d, sock| = %d, h|
|000019f0| 6f 73 74 6e 61 6d 65 20 | 3d 20 25 73 5c 6e 22 2c |ostname |= %s\n",|
|00001a00| 69 2c 63 6f 6e 6e 74 61 | 62 5b 69 5d 2e 63 5f 73 |i,connta|b[i].c_s|
|00001a10| 6f 63 6b 65 74 2c 0a 09 | 20 20 20 20 20 20 63 6f |ocket,..| co|
|00001a20| 6e 6e 74 61 62 5b 69 5d | 2e 63 5f 68 6f 73 74 6e |nntab[i]|.c_hostn|
|00001a30| 61 6d 65 29 3b 0a 20 20 | 20 20 20 20 77 72 69 74 |ame);. | writ|
|00001a40| 65 28 66 64 2c 6c 69 6e | 65 2c 73 74 72 6c 65 6e |e(fd,lin|e,strlen|
|00001a50| 28 6c 69 6e 65 29 29 3b | 7d 0a 20 20 7d 0a 20 20 |(line));|}. }. |
|00001a60| 63 6c 6f 73 65 28 66 64 | 29 3b 0a 7d 0a 0a 2f 2a |close(fd|);.}../*|
|00001a70| 20 43 6c 6f 73 65 20 74 | 68 65 20 63 6f 6e 6e 65 | Close t|he conne|
|00001a80| 63 74 69 6f 6e 20 6f 6e | 20 73 6f 63 6b 65 74 20 |ction on| socket |
|00001a90| 63 2c 20 73 61 76 69 6e | 67 20 74 68 65 20 77 65 |c, savin|g the we|
|00001aa0| 62 20 69 66 20 69 74 20 | 77 61 73 20 63 6f 6e 6e |b if it |was conn|
|00001ab0| 65 63 74 65 64 20 74 6f | 0a 20 20 20 61 20 70 72 |ected to|. a pr|
|00001ac0| 6f 76 69 64 65 72 2e 0a | 20 20 20 4e 6f 74 65 3a |ovider..| Note:|
|00001ad0| 20 53 68 6f 75 6c 64 20 | 74 68 65 72 65 20 62 65 | Should |there be|
|00001ae0| 20 61 20 6d 6f 64 69 66 | 69 65 64 20 66 6c 61 67 | a modif|ied flag|
|00001af0| 20 69 6e 20 74 68 65 20 | 70 72 6f 76 69 64 65 72 | in the |provider|
|00001b00| 27 73 20 73 6f 63 6b 65 | 74 20 69 6e 66 6f 20 74 |'s socke|t info t|
|00001b10| 6f 0a 20 20 20 20 20 20 | 20 20 20 64 65 74 65 72 |o. | deter|
|00001b20| 6d 69 6e 65 20 77 68 65 | 74 68 65 72 20 6f 72 20 |mine whe|ther or |
|00001b30| 6e 6f 74 20 77 65 20 6e | 65 65 64 20 74 6f 20 73 |not we n|eed to s|
|00001b40| 61 76 65 20 74 68 65 20 | 77 65 62 3f 20 0a 2a 2f |ave the |web? .*/|
|00001b50| 0a 76 6f 69 64 0a 63 6c | 6f 73 65 5f 63 6f 6e 6e |.void.cl|ose_conn|
|00001b60| 65 63 74 69 6f 6e 28 69 | 6e 74 20 63 29 0a 7b 0a |ection(i|nt c).{.|
|00001b70| 09 74 69 6d 65 5f 74 20 | 20 20 20 20 20 20 20 20 |.time_t | |
|00001b80| 20 73 65 63 73 3b 0a 09 | 63 68 61 72 20 20 20 20 | secs;..|char |
|00001b90| 20 20 20 6c 69 6e 65 5b | 31 32 30 5d 3b 0a 09 69 | line[|120];..i|
|00001ba0| 6e 74 20 72 63 3b 0a 0a | 09 74 69 6d 65 28 26 73 |nt rc;..|.time(&s|
|00001bb0| 65 63 73 29 3b 0a 09 69 | 66 20 28 64 65 62 75 67 |ecs);..i|f (debug|
|00001bc0| 29 20 7b 0a 09 20 20 70 | 72 69 6e 74 66 28 22 43 |) {.. p|rintf("C|
|00001bd0| 6c 6f 73 69 6e 67 20 63 | 6f 6e 6e 65 63 74 69 6f |losing c|onnectio|
|00001be0| 6e 20 74 6f 20 25 73 2c | 20 70 6f 72 74 20 25 64 |n to %s,| port %d|
|00001bf0| 2c 20 73 6f 63 6b 65 74 | 20 23 25 64 2e 5c 6e 22 |, socket| #%d.\n"|
|00001c00| 2c 0a 09 09 20 63 6f 6e | 6e 74 61 62 5b 63 5d 2e |,... con|ntab[c].|
|00001c10| 63 5f 68 6f 73 74 6e 61 | 6d 65 2c 0a 09 09 20 63 |c_hostna|me,... c|
|00001c20| 6f 6e 6e 74 61 62 5b 63 | 5d 2e 63 5f 70 6f 72 74 |onntab[c|].c_port|
|00001c30| 6e 75 6d 2c 0a 09 09 20 | 63 6f 6e 6e 74 61 62 5b |num,... |conntab[|
|00001c40| 63 5d 2e 63 5f 73 6f 63 | 6b 65 74 29 3b 0a 09 20 |c].c_soc|ket);.. |
|00001c50| 20 66 66 6c 75 73 68 28 | 73 74 64 6f 75 74 29 3b | fflush(|stdout);|
|00001c60| 0a 09 7d 0a 0a 09 73 70 | 72 69 6e 74 66 28 6c 69 |..}...sp|rintf(li|
|00001c70| 6e 65 2c 22 25 64 20 25 | 64 20 25 73 20 20 25 2e |ne,"%d %|d %s %.|
|00001c80| 32 34 73 2c 20 61 63 74 | 69 76 65 20 25 2e 31 66 |24s, act|ive %.1f|
|00001c90| 20 6d 69 6e 75 74 65 73 | 20 2d 20 53 45 52 56 45 | minutes| - SERVE|
|00001ca0| 52 5c 6e 22 2c 0a 09 09 | 63 6f 6e 6e 74 61 62 5b |R\n",...|conntab[|
|00001cb0| 63 5d 2e 63 5f 70 6f 72 | 74 6e 75 6d 2c 0a 09 09 |c].c_por|tnum,...|
|00001cc0| 63 6f 6e 6e 74 61 62 5b | 63 5d 2e 63 5f 73 6f 63 |conntab[|c].c_soc|
|00001cd0| 6b 65 74 2c 0a 09 09 63 | 6f 6e 6e 74 61 62 5b 63 |ket,...c|onntab[c|
|00001ce0| 5d 2e 63 5f 68 6f 73 74 | 6e 61 6d 65 2c 0a 09 09 |].c_host|name,...|
|00001cf0| 63 74 69 6d 65 28 26 73 | 65 63 73 29 2c 0a 09 09 |ctime(&s|ecs),...|
|00001d00| 28 66 6c 6f 61 74 29 20 | 28 28 73 65 63 73 20 2d |(float) |((secs -|
|00001d10| 20 63 6f 6e 6e 74 61 62 | 5b 63 5d 2e 63 5f 6d 61 | conntab|[c].c_ma|
|00001d20| 64 65 29 20 2f 36 30 2e | 30 29 29 3b 0a 09 6c 6f |de) /60.|0));..lo|
|00001d30| 67 5f 73 65 73 73 69 6f | 6e 28 6c 69 6e 65 29 3b |g_sessio|n(line);|
|00001d40| 0a 09 69 66 20 28 63 6f | 6e 6e 74 61 62 5b 63 5d |..if (co|nntab[c]|
|00001d50| 2e 63 5f 70 74 72 20 21 | 3d 20 4e 55 4c 4c 29 0a |.c_ptr !|= NULL).|
|00001d60| 09 20 20 72 65 6d 6f 76 | 65 5f 73 65 6e 64 28 63 |. remov|e_send(c|
|00001d70| 6f 6e 6e 74 61 62 5b 63 | 5d 2e 63 5f 70 74 72 29 |onntab[c|].c_ptr)|
|00001d80| 3b 0a 09 69 66 20 28 63 | 6f 6e 6e 74 61 62 5b 63 |;..if (c|onntab[c|
|00001d90| 5d 2e 63 5f 72 65 63 70 | 74 72 20 21 3d 20 4e 55 |].c_recp|tr != NU|
|00001da0| 4c 4c 29 0a 09 20 20 72 | 65 6d 6f 76 65 5f 72 65 |LL).. r|emove_re|
|00001db0| 63 28 63 6f 6e 6e 74 61 | 62 5b 63 5d 2e 63 5f 72 |c(connta|b[c].c_r|
|00001dc0| 65 63 70 74 72 29 3b 0a | 09 69 66 20 28 63 6f 6e |ecptr);.|.if (con|
|00001dd0| 6e 74 61 62 5b 63 5d 2e | 63 5f 68 70 74 72 20 21 |ntab[c].|c_hptr !|
|00001de0| 3d 20 4e 55 4c 4c 29 0a | 09 20 20 72 65 6d 6f 76 |= NULL).|. remov|
|00001df0| 65 5f 68 65 6c 70 65 72 | 28 63 6f 6e 6e 74 61 62 |e_helper|(conntab|
|00001e00| 5b 63 5d 2e 63 5f 68 70 | 74 72 29 3b 20 2f 2a 20 |[c].c_hp|tr); /* |
|00001e10| 73 65 6e 64 20 4b 49 4c | 4c 20 74 6f 20 63 68 69 |send KIL|L to chi|
|00001e20| 6c 64 20 2a 2f 0a 0a 09 | 64 6f 5f 66 72 65 65 28 |ld */...|do_free(|
|00001e30| 63 6f 6e 6e 74 61 62 5b | 63 5d 2e 63 5f 68 6f 73 |conntab[|c].c_hos|
|00001e40| 74 6e 61 6d 65 29 3b 0a | 09 64 6f 5f 66 72 65 65 |tname);.|.do_free|
|00001e50| 28 63 6f 6e 6e 74 61 62 | 5b 63 5d 2e 63 5f 75 69 |(conntab|[c].c_ui|
|00001e60| 64 29 3b 0a 09 64 6f 5f | 66 72 65 65 28 63 6f 6e |d);..do_|free(con|
|00001e70| 6e 74 61 62 5b 63 5d 2e | 63 5f 74 79 70 65 29 3b |ntab[c].|c_type);|
|00001e80| 0a 09 46 44 5f 43 4c 52 | 28 63 6f 6e 6e 74 61 62 |..FD_CLR|(conntab|
|00001e90| 5b 63 5d 2e 63 5f 73 6f | 63 6b 65 74 2c 20 26 72 |[c].c_so|cket, &r|
|00001ea0| 65 61 64 5f 66 64 73 29 | 3b 20 2f 2a 20 6e 6f 74 |ead_fds)|; /* not|
|00001eb0| 20 6e 65 65 64 65 64 20 | 6e 6f 77 20 3f 20 2a 2f | needed |now ? */|
|00001ec0| 0a 09 46 44 5f 43 4c 52 | 28 63 6f 6e 6e 74 61 62 |..FD_CLR|(conntab|
|00001ed0| 5b 63 5d 2e 63 5f 73 6f | 63 6b 65 74 2c 20 26 77 |[c].c_so|cket, &w|
|00001ee0| 72 69 74 65 5f 66 64 73 | 29 3b 0a 09 46 44 5f 43 |rite_fds|);..FD_C|
|00001ef0| 4c 52 28 63 6f 6e 6e 74 | 61 62 5b 63 5d 2e 63 5f |LR(connt|ab[c].c_|
|00001f00| 73 6f 63 6b 65 74 2c 20 | 26 65 78 63 65 70 74 5f |socket, |&except_|
|00001f10| 66 64 73 29 3b 0a 09 72 | 63 20 3d 20 63 6c 6f 73 |fds);..r|c = clos|
|00001f20| 65 28 63 6f 6e 6e 74 61 | 62 5b 63 5d 2e 63 5f 73 |e(connta|b[c].c_s|
|00001f30| 6f 63 6b 65 74 29 3b 0a | 09 69 66 20 28 72 63 20 |ocket);.|.if (rc |
|00001f40| 3c 20 30 29 20 7b 0a 09 | 20 20 73 70 72 69 6e 74 |< 0) {..| sprint|
|00001f50| 66 28 6c 69 6e 65 2c 22 | 43 6f 6e 6e 65 63 74 69 |f(line,"|Connecti|
|00001f60| 6f 6e 20 63 6c 6f 73 65 | 20 66 61 69 6c 65 64 20 |on close| failed |
|00001f70| 6f 6e 20 73 6f 63 6b 65 | 74 20 25 64 5c 6e 22 2c |on socke|t %d\n",|
|00001f80| 63 6f 6e 6e 74 61 62 5b | 63 5d 2e 63 5f 73 6f 63 |conntab[|c].c_soc|
|00001f90| 6b 65 74 29 3b 0a 09 20 | 20 70 72 69 6e 74 66 28 |ket);.. | printf(|
|00001fa0| 6c 69 6e 65 29 3b 20 66 | 66 6c 75 73 68 28 73 74 |line); f|flush(st|
|00001fb0| 64 6f 75 74 29 3b 0a 09 | 20 20 6c 6f 67 5f 73 65 |dout);..| log_se|
|00001fc0| 73 73 69 6f 6e 28 6c 69 | 6e 65 29 3b 0a 09 7d 0a |ssion(li|ne);..}.|
|00001fd0| 09 63 6f 6e 6e 74 61 62 | 5b 63 5d 2e 63 5f 73 6f |.conntab|[c].c_so|
|00001fe0| 63 6b 65 74 20 3d 20 2d | 31 3b 0a 09 63 6f 6e 6e |cket = -|1;..conn|
|00001ff0| 74 61 62 5b 63 5d 2e 63 | 5f 70 74 72 20 3d 20 4e |tab[c].c|_ptr = N|
|00002000| 55 4c 4c 3b 0a 09 63 6f | 6e 6e 74 61 62 5b 63 5d |ULL;..co|nntab[c]|
|00002010| 2e 63 5f 72 65 63 70 74 | 72 20 3d 20 4e 55 4c 4c |.c_recpt|r = NULL|
|00002020| 3b 0a 09 63 6f 6e 6e 74 | 61 62 5b 63 5d 2e 63 5f |;..connt|ab[c].c_|
|00002030| 68 70 74 72 20 3d 20 4e | 55 4c 4c 3b 0a 09 6e 75 |hptr = N|ULL;..nu|
|00002040| 6d 5f 63 6f 6e 6e 65 63 | 74 69 6f 6e 2d 2d 3b 0a |m_connec|tion--;.|
|00002050| 7d 0a 0a 0a 2f 2a 0a 20 | 2a 20 46 69 6e 64 20 74 |}.../*. |* Find t|
|00002060| 68 65 20 63 6f 6e 6e 65 | 63 74 69 6f 6e 20 75 73 |he conne|ction us|
|00002070| 69 6e 67 20 74 68 65 20 | 67 69 76 65 6e 20 73 6f |ing the |given so|
|00002080| 63 6b 65 74 2c 20 61 6e | 64 20 6d 61 72 6b 20 69 |cket, an|d mark i|
|00002090| 74 20 61 73 20 68 61 76 | 69 6e 67 0a 20 2a 20 74 |t as hav|ing. * t|
|000020a0| 69 6d 65 64 20 6f 75 74 | 2c 20 73 6f 20 74 68 65 |imed out|, so the|
|000020b0| 20 73 65 72 76 65 72 20 | 63 61 6e 20 63 6c 6f 73 | server |can clos|
|000020c0| 65 20 69 74 20 6f 66 66 | 20 6e 65 78 74 20 74 69 |e it off| next ti|
|000020d0| 6d 65 20 61 72 6f 75 6e | 64 2e 0a 20 2a 2f 0a 0a |me aroun|d.. */..|
|000020e0| 76 6f 69 64 0a 73 6f 63 | 6b 5f 74 69 6d 65 6f 75 |void.soc|k_timeou|
|000020f0| 74 28 69 6e 74 20 73 6f | 63 6b 29 0a 7b 0a 09 69 |t(int so|ck).{..i|
|00002100| 6e 74 09 69 3b 0a 0a 09 | 66 6f 72 20 28 69 20 3d |nt.i;...|for (i =|
|00002110| 20 30 3b 20 69 20 3c 20 | 46 44 5f 53 45 54 53 49 | 0; i < |FD_SETSI|
|00002120| 5a 45 3b 20 69 2b 2b 29 | 20 7b 0a 09 09 69 66 20 |ZE; i++)| {...if |
|00002130| 28 63 6f 6e 6e 74 61 62 | 5b 69 5d 2e 63 5f 73 6f |(conntab|[i].c_so|
|00002140| 63 6b 65 74 20 3d 3d 20 | 73 6f 63 6b 29 20 7b 0a |cket == |sock) {.|
|00002150| 09 09 09 63 6f 6e 6e 74 | 61 62 5b 69 5d 2e 63 5f |...connt|ab[i].c_|
|00002160| 66 6c 61 67 73 20 7c 3d | 20 43 5f 54 49 4d 45 4f |flags |=| C_TIMEO|
|00002170| 55 54 3b 0a 09 09 09 62 | 72 65 61 6b 3b 0a 09 09 |UT;....b|reak;...|
|00002180| 7d 0a 09 7d 0a 09 70 72 | 69 6e 74 66 28 22 53 6f |}..}..pr|intf("So|
|00002190| 63 6b 20 23 25 64 20 6d | 61 72 6b 65 64 20 66 6f |ck #%d m|arked fo|
|000021a0| 72 20 74 69 6d 65 6f 75 | 74 20 74 65 72 6d 69 6e |r timeou|t termin|
|000021b0| 61 74 69 6f 6e 2e 5c 6e | 22 2c 0a 09 09 63 6f 6e |ation.\n|",...con|
|000021c0| 6e 74 61 62 5b 69 5d 2e | 63 5f 73 6f 63 6b 65 74 |ntab[i].|c_socket|
|000021d0| 29 3b 0a 09 66 66 6c 75 | 73 68 28 73 74 64 6f 75 |);..fflu|sh(stdou|
|000021e0| 74 29 3b 0a 7d 0a 0a 76 | 6f 69 64 0a 73 65 72 76 |t);.}..v|oid.serv|
|000021f0| 65 72 5f 73 68 75 74 64 | 6f 77 6e 28 29 0a 7b 0a |er_shutd|own().{.|
|00002200| 09 69 6e 74 20 20 20 20 | 20 20 20 20 20 20 20 20 |.int | |
|00002210| 20 69 3b 0a 0a 09 73 61 | 76 65 5f 64 61 74 61 73 | i;...sa|ve_datas|
|00002220| 74 72 75 63 74 28 29 3b | 20 20 20 20 2f 2a 20 64 |truct();| /* d|
|00002230| 6f 20 74 68 69 73 20 66 | 6f 72 20 70 72 6f 64 75 |o this f|or produ|
|00002240| 63 74 69 6f 6e 20 6f 6e | 6c 79 3f 20 2a 2f 0a 09 |ction on|ly? */..|
|00002250| 6c 6f 67 5f 74 72 61 6e | 73 28 22 53 68 75 74 69 |log_tran|s("Shuti|
|00002260| 6e 67 20 64 6f 77 6e 20 | 74 68 65 20 73 65 72 76 |ng down |the serv|
|00002270| 65 72 22 29 3b 0a 09 70 | 75 74 73 28 22 5c 6e 53 |er");..p|uts("\nS|
|00002280| 65 72 76 65 72 20 73 68 | 75 74 64 6f 77 6e 2c 20 |erver sh|utdown, |
|00002290| 63 6c 6f 73 69 6e 67 20 | 63 6f 6e 6e 65 63 74 69 |closing |connecti|
|000022a0| 6f 6e 73 3a 22 29 3b 0a | 0a 09 66 6f 72 20 28 69 |ons:");.|..for (i|
|000022b0| 20 3d 20 30 3b 20 69 20 | 3c 20 46 44 5f 53 45 54 | = 0; i |< FD_SET|
|000022c0| 53 49 5a 45 3b 20 69 2b | 2b 29 09 2f 2a 20 43 6c |SIZE; i+|+)./* Cl|
|000022d0| 6f 73 65 20 43 6f 6e 6e | 65 63 74 69 6f 6e 73 20 |ose Conn|ections |
|000022e0| 2a 2f 0a 09 09 69 66 20 | 28 63 6f 6e 6e 5f 65 73 |*/...if |(conn_es|
|000022f0| 74 61 62 6c 69 73 68 65 | 64 28 69 29 29 0a 09 09 |tablishe|d(i))...|
|00002300| 09 63 6c 6f 73 65 5f 63 | 6f 6e 6e 65 63 74 69 6f |.close_c|onnectio|
|00002310| 6e 28 69 29 3b 0a 0a 09 | 63 6c 6f 73 65 28 6c 69 |n(i);...|close(li|
|00002320| 73 74 65 6e 5f 73 6f 63 | 6b 29 3b 20 20 0a 09 70 |sten_soc|k); ..p|
|00002330| 75 74 73 28 22 53 65 72 | 76 65 72 20 68 61 73 20 |uts("Ser|ver has |
|00002340| 73 68 75 74 20 64 6f 77 | 6e 20 2d 2d 20 45 78 69 |shut dow|n -- Exi|
|00002350| 74 69 6e 67 2e 22 29 3b | 0a 09 65 78 69 74 28 30 |ting.");|..exit(0|
|00002360| 29 3b 0a 7d 0a 0a 69 6e | 74 0a 68 64 6c 5f 63 6f |);.}..in|t.hdl_co|
|00002370| 6e 6e 65 63 74 28 69 6e | 74 20 63 29 0a 7b 0a 09 |nnect(in|t c).{..|
|00002380| 43 4f 4e 4e 20 20 20 20 | 20 20 20 20 20 20 20 2a |CONN | *|
|00002390| 63 6f 6e 6e 20 3d 20 26 | 63 6f 6e 6e 74 61 62 5b |conn = &|conntab[|
|000023a0| 63 5d 3b 0a 09 69 6e 74 | 20 20 20 20 20 20 20 20 |c];..int| |
|000023b0| 20 20 20 20 20 71 75 69 | 74 3b 0a 0a 09 69 66 20 | qui|t;...if |
|000023c0| 28 64 65 62 75 67 29 20 | 7b 0a 09 20 20 70 72 69 |(debug) |{.. pri|
|000023d0| 6e 74 66 28 22 5c 6e 48 | 61 6e 64 6c 69 6e 67 20 |ntf("\nH|andling |
|000023e0| 74 72 61 6e 73 61 63 74 | 69 6f 6e 20 74 6f 20 25 |transact|ion to %|
|000023f0| 73 2c 20 70 6f 72 74 20 | 25 64 2c 20 73 6f 63 6b |s, port |%d, sock|
|00002400| 65 74 20 23 25 64 2e 5c | 6e 22 2c 0a 09 09 20 63 |et #%d.\|n",... c|
|00002410| 6f 6e 6e 2d 3e 63 5f 68 | 6f 73 74 6e 61 6d 65 2c |onn->c_h|ostname,|
|00002420| 0a 09 09 20 63 6f 6e 6e | 2d 3e 63 5f 70 6f 72 74 |... conn|->c_port|
|00002430| 6e 75 6d 2c 0a 09 09 20 | 63 6f 6e 6e 2d 3e 63 5f |num,... |conn->c_|
|00002440| 73 6f 63 6b 65 74 29 3b | 0a 09 20 20 66 66 6c 75 |socket);|.. fflu|
|00002450| 73 68 28 73 74 64 6f 75 | 74 29 3b 0a 09 7d 0a 0a |sh(stdou|t);..}..|
|00002460| 09 71 75 69 74 20 3d 20 | 68 64 6c 5f 74 72 61 6e |.quit = |hdl_tran|
|00002470| 73 61 63 74 28 63 6f 6e | 6e 29 3b 0a 09 74 69 6d |sact(con|n);..tim|
|00002480| 65 28 26 63 6f 6e 6e 2d | 3e 63 5f 6c 61 73 74 29 |e(&conn-|>c_last)|
|00002490| 3b 0a 0a 09 72 65 74 75 | 72 6e 20 71 75 69 74 3b |;...retu|rn quit;|
|000024a0| 0a 7d 0a 0a 76 6f 69 64 | 0a 6d 61 6b 65 5f 6e 65 |.}..void|.make_ne|
|000024b0| 77 5f 63 6f 6e 6e 65 63 | 74 69 6f 6e 28 69 6e 74 |w_connec|tion(int|
|000024c0| 20 6c 69 73 74 65 6e 5f | 73 6f 63 6b 29 0a 7b 0a | listen_|sock).{.|
|000024d0| 09 43 4f 4e 4e 20 20 20 | 20 20 20 20 20 20 20 20 |.CONN | |
|000024e0| 2a 63 6f 6e 6e 3b 0a 09 | 63 68 61 72 20 20 20 20 |*conn;..|char |
|000024f0| 20 20 20 20 20 20 20 2a | 68 6f 73 74 6e 61 6d 65 | *|hostname|
|00002500| 2c 6c 69 6e 65 5b 31 30 | 30 5d 2c 2a 63 70 3b 0a |,line[10|0],*cp;.|
|00002510| 09 69 6e 74 20 20 20 20 | 20 20 20 20 20 20 20 20 |.int | |
|00002520| 69 3b 0a 09 74 69 6d 65 | 5f 74 20 20 20 20 73 65 |i;..time|_t se|
|00002530| 63 73 3b 0a 09 74 69 6d | 65 28 26 73 65 63 73 29 |cs;..tim|e(&secs)|
|00002540| 3b 0a 09 66 6f 72 20 28 | 69 20 3d 20 30 3b 20 69 |;..for (|i = 0; i|
|00002550| 20 3c 20 46 44 5f 53 45 | 54 53 49 5a 45 3b 20 69 | < FD_SE|TSIZE; i|
|00002560| 2b 2b 29 0a 09 20 20 69 | 66 20 28 21 63 6f 6e 6e |++).. i|f (!conn|
|00002570| 5f 65 73 74 61 62 6c 69 | 73 68 65 64 28 69 29 29 |_establi|shed(i))|
|00002580| 0a 09 20 20 20 20 62 72 | 65 61 6b 3b 0a 09 69 66 |.. br|eak;..if|
|00002590| 20 28 69 20 3d 3d 20 46 | 44 5f 53 45 54 53 49 5a | (i == F|D_SETSIZ|
|000025a0| 45 29 20 7b 0a 09 20 20 | 70 72 69 6e 74 66 28 22 |E) {.. |printf("|
|000025b0| 54 65 63 68 49 6e 66 6f | 20 73 65 72 76 65 72 3a |TechInfo| server:|
|000025c0| 20 72 65 61 63 68 65 64 | 20 63 6f 6e 6e 65 63 74 | reached| connect|
|000025d0| 69 6f 6e 20 6c 69 6d 69 | 74 20 6f 66 20 25 64 2e |ion limi|t of %d.|
|000025e0| 5c 6e 22 2c 0a 09 09 20 | 46 44 5f 53 45 54 53 49 |\n",... |FD_SETSI|
|000025f0| 5a 45 29 3b 0a 09 20 20 | 66 66 6c 75 73 68 28 73 |ZE);.. |fflush(s|
|00002600| 74 64 6f 75 74 29 3b 0a | 09 20 20 72 65 74 75 72 |tdout);.|. retur|
|00002610| 6e 3b 0a 09 7d 0a 09 63 | 6f 6e 6e 20 3d 20 26 63 |n;..}..c|onn = &c|
|00002620| 6f 6e 6e 74 61 62 5b 69 | 5d 3b 0a 0a 09 63 6f 6e |onntab[i|];...con|
|00002630| 6e 2d 3e 63 5f 73 6f 63 | 6b 65 74 20 3d 20 69 6e |n->c_soc|ket = in|
|00002640| 65 74 5f 61 63 63 65 70 | 74 5f 63 6f 6e 6e 65 63 |et_accep|t_connec|
|00002650| 74 69 6f 6e 28 6c 69 73 | 74 65 6e 5f 73 6f 63 6b |tion(lis|ten_sock|
|00002660| 2c 20 26 68 6f 73 74 6e | 61 6d 65 2c 0a 09 09 09 |, &hostn|ame,....|
|00002670| 09 09 09 26 63 6f 6e 6e | 2d 3e 63 5f 70 6f 72 74 |...&conn|->c_port|
|00002680| 6e 75 6d 29 3b 0a 0a 09 | 69 66 20 28 63 6f 6e 6e |num);...|if (conn|
|00002690| 2d 3e 63 5f 73 6f 63 6b | 65 74 20 3d 3d 20 2d 31 |->c_sock|et == -1|
|000026a0| 29 20 7b 0a 09 09 70 75 | 74 73 28 22 61 63 63 65 |) {...pu|ts("acce|
|000026b0| 70 74 5f 63 6f 6e 6e 65 | 63 74 69 6f 6e 20 66 61 |pt_conne|ction fa|
|000026c0| 69 6c 65 64 22 29 3b 0a | 09 09 72 65 74 75 72 6e |iled");.|..return|
|000026d0| 3b 0a 09 7d 0a 09 69 66 | 20 28 50 45 4e 44 49 4e |;..}..if| (PENDIN|
|000026e0| 47 5f 53 48 55 54 44 4f | 57 4e 29 20 2f 2a 20 64 |G_SHUTDO|WN) /* d|
|000026f0| 6f 6e 27 74 20 61 63 63 | 65 70 74 20 6e 65 77 20 |on't acc|ept new |
|00002700| 63 6f 6e 6e 65 63 74 69 | 6f 6e 73 20 2a 2f 0a 09 |connecti|ons */..|
|00002710| 20 20 7b 20 20 2f 2a 20 | 73 65 6e 64 20 61 6c 74 | { /* |send alt|
|00002720| 65 72 6e 61 74 65 20 6d | 65 73 73 61 67 65 20 61 |ernate m|essage a|
|00002730| 6e 64 20 63 6c 6f 73 65 | 20 63 6f 6e 6e 65 63 74 |nd close| connect|
|00002740| 69 6f 6e 20 64 6f 77 6e | 20 2a 2f 0a 09 20 20 20 |ion down| */.. |
|00002750| 20 69 66 20 28 73 68 75 | 74 64 6f 77 6e 5f 6d 73 | if (shu|tdown_ms|
|00002760| 67 29 20 0a 09 20 20 20 | 20 20 20 7b 0a 09 09 77 |g) .. | {...w|
|00002770| 72 69 74 65 28 63 6f 6e | 6e 2d 3e 63 5f 73 6f 63 |rite(con|n->c_soc|
|00002780| 6b 65 74 2c 20 73 68 75 | 74 64 6f 77 6e 5f 6d 73 |ket, shu|tdown_ms|
|00002790| 67 2c 20 73 74 72 6c 65 | 6e 28 73 68 75 74 64 6f |g, strle|n(shutdo|
|000027a0| 77 6e 5f 6d 73 67 29 29 | 3b 0a 09 09 77 72 69 74 |wn_msg))|;...writ|
|000027b0| 65 28 63 6f 6e 6e 2d 3e | 63 5f 73 6f 63 6b 65 74 |e(conn->|c_socket|
|000027c0| 2c 20 45 4f 4d 2c 20 45 | 4f 4d 5f 4c 45 4e 29 3b |, EOM, E|OM_LEN);|
|000027d0| 0a 09 20 20 20 20 20 20 | 7d 0a 09 20 20 20 20 65 |.. |}.. e|
|000027e0| 6c 73 65 20 0a 09 20 20 | 20 20 20 20 7b 0a 09 09 |lse .. | {...|
|000027f0| 77 72 69 74 65 28 63 6f | 6e 6e 2d 3e 63 5f 73 6f |write(co|nn->c_so|
|00002800| 63 6b 65 74 2c 20 4e 41 | 4b 5f 42 41 4e 4e 45 52 |cket, NA|K_BANNER|
|00002810| 2c 20 73 74 72 6c 65 6e | 28 4e 41 4b 5f 42 41 4e |, strlen|(NAK_BAN|
|00002820| 4e 45 52 29 29 3b 0a 09 | 09 77 72 69 74 65 28 63 |NER));..|.write(c|
|00002830| 6f 6e 6e 2d 3e 63 5f 73 | 6f 63 6b 65 74 2c 20 45 |onn->c_s|ocket, E|
|00002840| 4f 4d 2c 20 45 4f 4d 5f | 4c 45 4e 29 3b 0a 09 20 |OM, EOM_|LEN);.. |
|00002850| 20 20 20 20 20 7d 0a 09 | 20 20 20 20 2f 2a 20 70 | }..| /* p|
|00002860| 6f 73 73 69 62 6c 79 20 | 73 6c 65 65 70 20 3f 3f |ossibly |sleep ??|
|00002870| 20 2a 2f 0a 09 20 20 20 | 20 63 6c 6f 73 65 28 63 | */.. | close(c|
|00002880| 6f 6e 6e 2d 3e 63 5f 73 | 6f 63 6b 65 74 29 3b 0a |onn->c_s|ocket);.|
|00002890| 09 20 20 20 20 63 6f 6e | 6e 2d 3e 63 5f 73 6f 63 |. con|n->c_soc|
|000028a0| 6b 65 74 20 3d 20 2d 31 | 3b 0a 09 20 20 20 20 72 |ket = -1|;.. r|
|000028b0| 65 74 75 72 6e 3b 0a 09 | 20 20 7d 0a 09 63 6f 6e |eturn;..| }..con|
|000028c0| 6e 2d 3e 63 5f 68 6f 73 | 74 6e 61 6d 65 20 3d 20 |n->c_hos|tname = |
|000028d0| 28 63 68 61 72 20 2a 29 | 20 64 6f 6d 61 6c 6c 6f |(char *)| domallo|
|000028e0| 63 28 28 75 6e 73 69 67 | 6e 65 64 20 69 6e 74 29 |c((unsig|ned int)|
|000028f0| 20 73 74 72 6c 65 6e 28 | 68 6f 73 74 6e 61 6d 65 | strlen(|hostname|
|00002900| 29 20 2b 20 31 29 3b 0a | 09 73 74 72 63 70 79 28 |) + 1);.|.strcpy(|
|00002910| 63 6f 6e 6e 2d 3e 63 5f | 68 6f 73 74 6e 61 6d 65 |conn->c_|hostname|
|00002920| 2c 20 68 6f 73 74 6e 61 | 6d 65 29 3b 0a 09 63 6f |, hostna|me);..co|
|00002930| 6e 6e 2d 3e 63 5f 75 69 | 64 20 3d 20 28 63 68 61 |nn->c_ui|d = (cha|
|00002940| 72 20 2a 29 20 64 6f 6d | 61 6c 6c 6f 63 28 28 75 |r *) dom|alloc((u|
|00002950| 6e 73 69 67 6e 65 64 20 | 69 6e 74 29 20 32 35 29 |nsigned |int) 25)|
|00002960| 3b 0a 09 2a 63 6f 6e 6e | 2d 3e 63 5f 75 69 64 20 |;..*conn|->c_uid |
|00002970| 3d 20 27 5c 30 27 3b 0a | 09 63 6f 6e 6e 2d 3e 63 |= '\0';.|.conn->c|
|00002980| 5f 66 6c 61 67 73 20 3d | 20 30 3b 0a 09 63 6f 6e |_flags =| 0;..con|
|00002990| 6e 2d 3e 63 5f 74 79 70 | 65 20 3d 20 4e 55 4c 4c |n->c_typ|e = NULL|
|000029a0| 3b 0a 09 63 6f 6e 6e 2d | 3e 63 5f 6c 61 73 74 20 |;..conn-|>c_last |
|000029b0| 3d 20 74 69 6d 65 28 26 | 63 6f 6e 6e 2d 3e 63 5f |= time(&|conn->c_|
|000029c0| 6d 61 64 65 29 3b 0a 09 | 63 6f 6e 6e 2d 3e 63 5f |made);..|conn->c_|
|000029d0| 70 74 72 20 3d 20 4e 55 | 4c 4c 3b 0a 09 63 6f 6e |ptr = NU|LL;..con|
|000029e0| 6e 2d 3e 63 5f 72 65 63 | 70 74 72 20 3d 20 4e 55 |n->c_rec|ptr = NU|
|000029f0| 4c 4c 3b 0a 09 63 6f 6e | 6e 2d 3e 63 5f 68 70 74 |LL;..con|n->c_hpt|
|00002a00| 72 20 3d 20 4e 55 4c 4c | 3b 0a 09 63 6f 6e 6e 2d |r = NULL|;..conn-|
|00002a10| 3e 63 5f 74 72 61 6e 73 | 5f 63 6e 74 20 3d 20 30 |>c_trans|_cnt = 0|
|00002a20| 3b 0a 09 2f 2a 20 41 64 | 64 65 64 20 38 2f 31 32 |;../* Ad|ded 8/12|
|00002a30| 2f 39 32 20 61 72 6b 20 | 2d 2d 20 53 65 74 20 69 |/92 ark |-- Set i|
|00002a40| 6e 69 74 69 61 6c 20 6f | 75 74 70 75 74 20 66 6f |nitial o|utput fo|
|00002a50| 72 6d 61 74 20 74 6f 20 | 74 68 61 74 20 64 65 66 |rmat to |that def|
|00002a60| 69 6e 65 64 20 69 6e 20 | 6e 65 74 77 6f 72 6b 2e |ined in |network.|
|00002a70| 68 0a 09 20 20 20 43 68 | 61 6e 67 65 20 77 69 74 |h.. Ch|ange wit|
|00002a80| 68 20 74 68 65 20 27 6f | 27 20 74 72 61 6e 73 61 |h the 'o|' transa|
|00002a90| 63 74 69 6f 6e 20 2a 2f | 0a 09 63 6f 6e 6e 2d 3e |ction */|..conn->|
|00002aa0| 63 5f 6f 75 74 70 75 74 | 5f 66 6d 74 20 3d 20 44 |c_output|_fmt = D|
|00002ab0| 45 46 41 55 4c 54 5f 4f | 55 54 50 55 54 5f 46 4f |EFAULT_O|UTPUT_FO|
|00002ac0| 52 4d 41 54 3b 0a 0a 09 | 6e 75 6d 5f 63 6f 6e 6e |RMAT;...|num_conn|
|00002ad0| 65 63 74 69 6f 6e 2b 2b | 3b 0a 09 69 66 20 28 64 |ection++|;..if (d|
|00002ae0| 65 62 75 67 29 20 7b 0a | 09 20 20 70 72 69 6e 74 |ebug) {.|. print|
|00002af0| 66 28 22 41 63 63 65 70 | 74 65 64 20 6e 65 77 20 |f("Accep|ted new |
|00002b00| 63 6f 6e 6e 65 63 74 69 | 6f 6e 20 74 6f 20 25 73 |connecti|on to %s|
|00002b10| 2c 20 74 68 72 75 20 70 | 6f 72 74 20 25 64 2c 20 |, thru p|ort %d, |
|00002b20| 6f 76 65 72 20 73 6f 63 | 6b 65 74 20 23 25 64 2e |over soc|ket #%d.|
|00002b30| 5c 6e 22 2c 0a 09 20 20 | 20 20 20 20 20 63 6f 6e |\n",.. | con|
|00002b40| 6e 2d 3e 63 5f 68 6f 73 | 74 6e 61 6d 65 2c 0a 09 |n->c_hos|tname,..|
|00002b50| 20 20 20 20 20 20 20 63 | 6f 6e 6e 2d 3e 63 5f 70 | c|onn->c_p|
|00002b60| 6f 72 74 6e 75 6d 2c 0a | 09 20 20 20 20 20 20 20 |ortnum,.|. |
|00002b70| 63 6f 6e 6e 2d 3e 63 5f | 73 6f 63 6b 65 74 29 3b |conn->c_|socket);|
|00002b80| 0a 09 20 20 66 66 6c 75 | 73 68 28 73 74 64 6f 75 |.. fflu|sh(stdou|
|00002b90| 74 29 3b 0a 09 7d 0a 09 | 69 66 20 28 41 4c 54 5f |t);..}..|if (ALT_|
|00002ba0| 42 41 4e 4e 45 52 29 20 | 7b 0a 09 20 20 77 72 69 |BANNER) |{.. wri|
|00002bb0| 74 65 28 63 6f 6e 6e 2d | 3e 63 5f 73 6f 63 6b 65 |te(conn-|>c_socke|
|00002bc0| 74 2c 20 61 6c 74 5f 62 | 61 6e 6e 65 72 2c 20 73 |t, alt_b|anner, s|
|00002bd0| 74 72 6c 65 6e 28 61 6c | 74 5f 62 61 6e 6e 65 72 |trlen(al|t_banner|
|00002be0| 29 29 3b 0a 09 20 20 77 | 72 69 74 65 28 63 6f 6e |));.. w|rite(con|
|00002bf0| 6e 2d 3e 63 5f 73 6f 63 | 6b 65 74 2c 20 45 4f 4d |n->c_soc|ket, EOM|
|00002c00| 2c 20 45 4f 4d 5f 4c 45 | 4e 29 3b 0a 09 7d 0a 09 |, EOM_LE|N);..}..|
|00002c10| 65 6c 73 65 20 7b 0a 09 | 20 20 77 72 69 74 65 28 |else {..| write(|
|00002c20| 63 6f 6e 6e 2d 3e 63 5f | 73 6f 63 6b 65 74 2c 20 |conn->c_|socket, |
|00002c30| 42 41 4e 4e 45 52 2c 20 | 73 74 72 6c 65 6e 28 42 |BANNER, |strlen(B|
|00002c40| 41 4e 4e 45 52 29 29 3b | 0a 09 20 20 77 72 69 74 |ANNER));|.. writ|
|00002c50| 65 28 63 6f 6e 6e 2d 3e | 63 5f 73 6f 63 6b 65 74 |e(conn->|c_socket|
|00002c60| 2c 20 45 4f 4d 2c 20 45 | 4f 4d 5f 4c 45 4e 29 3b |, EOM, E|OM_LEN);|
|00002c70| 0a 09 7d 0a 0a 09 69 66 | 20 28 66 63 6e 74 6c 28 |..}...if| (fcntl(|
|00002c80| 63 6f 6e 6e 2d 3e 63 5f | 73 6f 63 6b 65 74 2c 20 |conn->c_|socket, |
|00002c90| 46 5f 53 45 54 46 4c 2c | 20 46 4e 44 45 4c 41 59 |F_SETFL,| FNDELAY|
|00002ca0| 29 20 3d 3d 20 2d 31 29 | 0a 09 09 70 65 72 72 6f |) == -1)|...perro|
|00002cb0| 72 28 22 66 63 6e 74 6c | 22 29 3b 0a 0a 09 2f 2a |r("fcntl|");.../*|
|00002cc0| 0a 09 20 2a 20 57 65 20 | 73 68 6f 75 6c 64 20 74 |.. * We |should t|
|00002cd0| 75 72 6e 20 62 6c 6f 63 | 6b 69 6e 67 20 6f 6e 20 |urn bloc|king on |
|00002ce0| 42 45 46 4f 52 45 20 77 | 72 69 74 65 20 74 68 65 |BEFORE w|rite the|
|00002cf0| 20 62 61 6e 6e 65 72 21 | 20 20 54 68 6f 73 65 0a | banner!| Those.|
|00002d00| 09 20 2a 20 77 72 69 74 | 65 73 20 73 68 6f 75 6c |. * writ|es shoul|
|00002d10| 64 6e 27 74 20 62 65 20 | 64 69 72 65 63 74 20 73 |dn't be |direct s|
|00002d20| 79 73 63 61 6c 6c 73 20 | 65 69 74 68 65 72 2e 0a |yscalls |either..|
|00002d30| 09 20 2a 2f 0a 09 69 66 | 20 28 63 6f 6e 6e 2d 3e |. */..if| (conn->|
|00002d40| 63 5f 74 79 70 65 20 3d | 3d 20 4e 55 4c 4c 29 0a |c_type =|= NULL).|
|00002d50| 09 20 20 63 70 20 3d 20 | 22 75 6e 6b 6e 6f 77 6e |. cp = |"unknown|
|00002d60| 22 3b 0a 09 65 6c 73 65 | 0a 09 20 20 63 70 20 3d |";..else|.. cp =|
|00002d70| 20 63 6f 6e 6e 2d 3e 63 | 5f 74 79 70 65 3b 0a 09 | conn->c|_type;..|
|00002d80| 73 70 72 69 6e 74 66 28 | 6c 69 6e 65 2c 22 25 64 |sprintf(|line,"%d|
|00002d90| 20 25 64 20 25 73 20 25 | 73 20 25 2e 32 34 73 20 | %d %s %|s %.24s |
|00002da0| 2d 20 53 45 52 56 45 52 | 5c 6e 22 2c 0a 09 09 63 |- SERVER|\n",...c|
|00002db0| 6f 6e 6e 2d 3e 63 5f 70 | 6f 72 74 6e 75 6d 2c 0a |onn->c_p|ortnum,.|
|00002dc0| 09 09 63 6f 6e 6e 2d 3e | 63 5f 73 6f 63 6b 65 74 |..conn->|c_socket|
|00002dd0| 2c 0a 09 09 63 6f 6e 6e | 2d 3e 63 5f 68 6f 73 74 |,...conn|->c_host|
|00002de0| 6e 61 6d 65 2c 0a 09 20 | 20 20 20 20 20 20 20 63 |name,.. | c|
|00002df0| 70 2c 0a 09 09 63 74 69 | 6d 65 28 26 73 65 63 73 |p,...cti|me(&secs|
|00002e00| 29 29 3b 0a 09 6c 6f 67 | 5f 73 65 73 73 69 6f 6e |));..log|_session|
|00002e10| 28 6c 69 6e 65 29 3b 0a | 09 09 0a 7d 0a 0a 69 6e |(line);.|...}..in|
|00002e20| 74 20 20 20 20 20 20 20 | 20 20 20 20 20 20 53 74 |t | St|
|00002e30| 61 6e 64 61 6c 6f 6e 65 | 20 3d 20 31 3b 0a 0a 73 |andalone| = 1;..s|
|00002e40| 74 61 74 69 63 09 69 6e | 74 20 20 20 20 20 20 20 |tatic.in|t |
|00002e50| 20 20 20 20 20 20 69 2c | 20 68 61 6e 64 6c 65 64 | i,| handled|
|00002e60| 3b 0a 73 74 61 74 69 63 | 09 74 69 6d 65 5f 74 20 |;.static|.time_t |
|00002e70| 20 20 20 20 20 20 20 20 | 20 73 65 63 73 3b 0a 0a | | secs;..|
|00002e80| 69 6e 74 09 41 63 74 69 | 76 65 4a 6f 62 73 20 3d |int.Acti|veJobs =|
|00002e90| 20 30 3b 09 09 2f 2a 20 | 4e 75 6d 62 65 72 20 6f | 0;../* |Number o|
|00002ea0| 66 20 70 65 6e 64 69 6e | 67 20 73 65 6e 64 73 20 |f pendin|g sends |
|00002eb0| 26 20 72 65 63 76 73 20 | 0a 09 09 09 09 20 73 65 |& recvs |..... se|
|00002ec0| 74 20 69 6e 74 20 6e 65 | 74 69 6f 2e 63 20 2a 2f |t int ne|tio.c */|
|00002ed0| 0a 0a 73 74 61 74 69 63 | 09 43 4f 4e 4e 09 09 2a |..static|.CONN..*|
|00002ee0| 63 6f 6e 6e 3b 0a 0a 65 | 78 74 65 72 6e 20 69 6e |conn;..e|xtern in|
|00002ef0| 74 20 6d 61 78 5f 73 74 | 61 6c 65 5f 74 69 6d 65 |t max_st|ale_time|
|00002f00| 3b 20 2f 2a 20 69 6e 20 | 73 68 75 74 64 6f 77 6e |; /* in |shutdown|
|00002f10| 20 6d 6f 64 65 20 77 61 | 69 74 20 75 6e 74 69 6c | mode wa|it until|
|00002f20| 20 61 6c 6c 20 63 6f 6e | 6e 20 68 61 76 65 20 62 | all con|n have b|
|00002f30| 65 65 6e 20 0a 09 09 09 | 20 20 20 20 20 20 69 6e |een ....| in|
|00002f40| 61 63 74 69 76 65 20 66 | 6f 72 20 74 68 69 73 20 |active f|or this |
|00002f50| 6d 61 6e 79 20 6d 69 6e | 75 74 65 73 20 2a 2f 0a |many min|utes */.|
|00002f60| 76 6f 69 64 0a 73 65 72 | 76 65 72 5f 6c 6f 6f 70 |void.ser|ver_loop|
|00002f70| 28 76 6f 69 64 29 0a 7b | 0a 20 20 69 6e 74 09 09 |(void).{|. int..|
|00002f80| 61 63 74 69 76 65 5f 73 | 6f 63 6b 73 2c 20 73 68 |active_s|ocks, sh|
|00002f90| 6f 77 5f 63 6f 6e 6e 65 | 63 74 20 3d 20 30 2c 20 |ow_conne|ct = 0, |
|00002fa0| 64 6f 5f 73 68 75 74 64 | 6f 77 6e 3b 0a 20 20 63 |do_shutd|own;. c|
|00002fb0| 68 61 72 20 6c 69 6e 65 | 5b 32 30 30 5d 3b 0a 20 |har line|[200];. |
|00002fc0| 20 73 74 72 75 63 74 20 | 74 69 6d 65 76 61 6c 09 | struct |timeval.|
|00002fd0| 74 76 3b 0a 20 20 0a 20 | 20 74 76 2e 74 76 5f 73 |tv;. . | tv.tv_s|
|00002fe0| 65 63 20 3d 20 30 3b 09 | 09 2f 2a 20 46 6f 72 20 |ec = 0;.|./* For |
|00002ff0| 6f 75 72 20 73 65 6c 65 | 63 74 20 77 68 65 6e 20 |our sele|ct when |
|00003000| 69 74 20 6f 6e 6c 79 20 | 70 6f 6c 6c 73 20 2a 2f |it only |polls */|
|00003010| 0a 20 20 74 76 2e 74 76 | 5f 75 73 65 63 20 3d 20 |. tv.tv|_usec = |
|00003020| 30 3b 0a 0a 20 20 61 6c | 61 72 6d 77 65 6e 74 6f |0;.. al|armwento|
|00003030| 66 66 20 3d 20 31 3b 0a | 20 20 73 69 67 6e 61 6c |ff = 1;.| signal|
|00003040| 20 28 53 49 47 41 4c 52 | 4d 2c 20 63 61 74 63 68 | (SIGALR|M, catch|
|00003050| 5f 61 6c 61 72 6d 29 3b | 0a 0a 20 20 66 6f 72 20 |_alarm);|.. for |
|00003060| 28 3b 3b 29 20 7b 0a 20 | 20 20 20 69 66 20 28 61 |(;;) {. | if (a|
|00003070| 6c 61 72 6d 77 65 6e 74 | 6f 66 66 29 20 7b 0a 20 |larmwent|off) {. |
|00003080| 20 20 20 20 20 61 6c 61 | 72 6d 77 65 6e 74 6f 66 | ala|rmwentof|
|00003090| 66 20 3d 20 30 3b 0a 20 | 20 20 20 20 20 73 61 76 |f = 0;. | sav|
|000030a0| 65 5f 64 61 74 61 73 74 | 72 75 63 74 28 29 3b 0a |e_datast|ruct();.|
|000030b0| 20 20 20 20 20 20 61 6c | 61 72 6d 28 36 30 29 3b | al|arm(60);|
|000030c0| 20 20 20 2f 2a 20 73 65 | 74 20 61 6c 61 72 6d 20 | /* se|t alarm |
|000030d0| 66 6f 72 20 31 20 6d 69 | 6e 75 74 65 20 2a 2f 0a |for 1 mi|nute */.|
|000030e0| 20 20 20 20 7d 0a 0a 20 | 20 20 20 69 66 20 28 50 | }.. | if (P|
|000030f0| 45 4e 44 49 4e 47 5f 53 | 48 55 54 44 4f 57 4e 29 |ENDING_S|HUTDOWN)|
|00003100| 0a 20 20 20 20 20 20 64 | 6f 5f 73 68 75 74 64 6f |. d|o_shutdo|
|00003110| 77 6e 20 3d 20 54 52 55 | 45 3b 0a 20 20 20 20 69 |wn = TRU|E;. i|
|00003120| 66 20 28 21 41 63 74 69 | 76 65 4a 6f 62 73 29 0a |f (!Acti|veJobs).|
|00003130| 20 20 20 20 20 20 73 68 | 6f 77 5f 63 6f 6e 6e 65 | sh|ow_conne|
|00003140| 63 74 2b 2b 3b 0a 20 20 | 20 20 69 66 20 28 73 68 |ct++;. | if (sh|
|00003150| 6f 77 5f 63 6f 6e 6e 65 | 63 74 20 26 26 20 64 65 |ow_conne|ct && de|
|00003160| 62 75 67 20 26 26 20 6e | 75 6d 5f 63 6f 6e 6e 65 |bug && n|um_conne|
|00003170| 63 74 69 6f 6e 29 20 7b | 0a 20 20 20 20 20 20 70 |ction) {|. p|
|00003180| 72 69 6e 74 66 28 22 5c | 6e 43 75 72 72 65 6e 74 |rintf("\|nCurrent|
|00003190| 20 63 6f 6e 6e 65 63 74 | 69 6f 6e 73 3a 22 29 3b | connect|ions:");|
|000031a0| 0a 20 20 20 20 20 20 66 | 66 6c 75 73 68 28 73 74 |. f|flush(st|
|000031b0| 64 6f 75 74 29 3b 0a 20 | 20 20 20 7d 0a 20 20 20 |dout);. | }. |
|000031c0| 20 46 44 5f 5a 45 52 4f | 28 26 72 65 61 64 5f 66 | FD_ZERO|(&read_f|
|000031d0| 64 73 29 3b 0a 20 20 20 | 20 46 44 5f 5a 45 52 4f |ds);. | FD_ZERO|
|000031e0| 28 26 77 72 69 74 65 5f | 66 64 73 29 3b 0a 20 20 |(&write_|fds);. |
|000031f0| 20 20 46 44 5f 5a 45 52 | 4f 28 26 65 78 63 65 70 | FD_ZER|O(&excep|
|00003200| 74 5f 66 64 73 29 3b 0a | 20 20 20 20 46 44 5f 53 |t_fds);.| FD_S|
|00003210| 45 54 28 6c 69 73 74 65 | 6e 5f 73 6f 63 6b 2c 20 |ET(liste|n_sock, |
|00003220| 26 72 65 61 64 5f 66 64 | 73 29 3b 0a 20 20 20 20 |&read_fd|s);. |
|00003230| 74 69 6d 65 28 26 73 65 | 63 73 29 3b 0a 20 20 20 |time(&se|cs);. |
|00003240| 20 66 6f 72 20 28 69 20 | 3d 20 30 3b 20 69 20 3c | for (i |= 0; i <|
|00003250| 20 46 44 5f 53 45 54 53 | 49 5a 45 3b 20 69 2b 2b | FD_SETS|IZE; i++|
|00003260| 29 20 7b 0a 20 20 20 20 | 20 20 69 66 20 28 21 63 |) {. | if (!c|
|00003270| 6f 6e 6e 5f 65 73 74 61 | 62 6c 69 73 68 65 64 28 |onn_esta|blished(|
|00003280| 69 29 29 0a 09 63 6f 6e | 74 69 6e 75 65 3b 0a 20 |i))..con|tinue;. |
|00003290| 20 20 20 20 20 63 6f 6e | 6e 20 3d 20 26 63 6f 6e | con|n = &con|
|000032a0| 6e 74 61 62 5b 69 5d 3b | 0a 20 20 20 20 20 20 69 |ntab[i];|. i|
|000032b0| 66 20 28 63 6f 6e 6e 5f | 77 61 69 74 5f 77 72 69 |f (conn_|wait_wri|
|000032c0| 74 65 28 69 29 29 0a 09 | 46 44 5f 53 45 54 28 63 |te(i))..|FD_SET(c|
|000032d0| 6f 6e 6e 2d 3e 63 5f 73 | 6f 63 6b 65 74 2c 20 26 |onn->c_s|ocket, &|
|000032e0| 77 72 69 74 65 5f 66 64 | 73 29 3b 20 0a 20 20 20 |write_fd|s); . |
|000032f0| 20 20 20 65 6c 73 65 0a | 09 46 44 5f 53 45 54 28 | else.|.FD_SET(|
|00003300| 63 6f 6e 6e 2d 3e 63 5f | 73 6f 63 6b 65 74 2c 20 |conn->c_|socket, |
|00003310| 26 72 65 61 64 5f 66 64 | 73 29 3b 0a 20 20 20 20 |&read_fd|s);. |
|00003320| 20 20 46 44 5f 53 45 54 | 28 63 6f 6e 6e 2d 3e 63 | FD_SET|(conn->c|
|00003330| 5f 73 6f 63 6b 65 74 2c | 20 26 65 78 63 65 70 74 |_socket,| &except|
|00003340| 5f 66 64 73 29 3b 0a 20 | 20 20 20 20 20 0a 20 20 |_fds);. | . |
|00003350| 20 20 20 20 69 66 20 28 | 21 73 68 6f 77 5f 63 6f | if (|!show_co|
|00003360| 6e 6e 65 63 74 29 0a 09 | 63 6f 6e 74 69 6e 75 65 |nnect)..|continue|
|00003370| 3b 0a 20 20 20 20 20 20 | 69 66 20 28 64 65 62 75 |;. |if (debu|
|00003380| 67 29 20 7b 0a 09 70 72 | 69 6e 74 66 28 22 5c 6e |g) {..pr|intf("\n|
|00003390| 23 25 32 64 20 20 25 73 | 2e 25 64 5c 74 61 63 74 |#%2d %s|.%d\tact|
|000033a0| 69 76 65 20 25 2e 31 66 | 2c 20 6c 61 73 74 20 25 |ive %.1f|, last %|
|000033b0| 2e 31 66 22 2c 0a 09 20 | 20 20 20 20 20 20 63 6f |.1f",.. | co|
|000033c0| 6e 6e 2d 3e 63 5f 73 6f | 63 6b 65 74 2c 0a 09 20 |nn->c_so|cket,.. |
|000033d0| 20 20 20 20 20 20 63 6f | 6e 6e 2d 3e 63 5f 68 6f | co|nn->c_ho|
|000033e0| 73 74 6e 61 6d 65 2c 0a | 09 20 20 20 20 20 20 20 |stname,.|. |
|000033f0| 63 6f 6e 6e 2d 3e 63 5f | 70 6f 72 74 6e 75 6d 2c |conn->c_|portnum,|
|00003400| 0a 09 20 20 20 20 20 20 | 20 28 66 6c 6f 61 74 29 |.. | (float)|
|00003410| 20 28 73 65 63 73 20 2d | 20 63 6f 6e 6e 2d 3e 63 | (secs -| conn->c|
|00003420| 5f 6d 61 64 65 29 20 2f | 20 36 30 2e 30 2c 0a 09 |_made) /| 60.0,..|
|00003430| 20 20 20 20 20 20 20 28 | 66 6c 6f 61 74 29 20 28 | (|float) (|
|00003440| 73 65 63 73 20 2d 20 63 | 6f 6e 6e 2d 3e 63 5f 6c |secs - c|onn->c_l|
|00003450| 61 73 74 29 20 2f 20 36 | 30 2e 30 29 3b 0a 09 66 |ast) / 6|0.0);..f|
|00003460| 66 6c 75 73 68 28 73 74 | 64 6f 75 74 29 3b 0a 20 |flush(st|dout);. |
|00003470| 20 20 20 20 20 7d 0a 20 | 20 20 20 20 20 69 66 20 | }. | if |
|00003480| 28 63 6f 6e 6e 2d 3e 63 | 5f 70 74 72 20 21 3d 20 |(conn->c|_ptr != |
|00003490| 4e 55 4c 4c 20 7c 20 63 | 6f 6e 6e 2d 3e 63 5f 72 |NULL | c|onn->c_r|
|000034a0| 65 63 70 74 72 20 21 3d | 20 4e 55 4c 4c 29 20 7b |ecptr !=| NULL) {|
|000034b0| 0a 09 69 66 20 28 28 28 | 73 65 63 73 20 2d 20 63 |..if (((|secs - c|
|000034c0| 6f 6e 6e 2d 3e 63 5f 6c | 61 73 74 29 20 2f 20 36 |onn->c_l|ast) / 6|
|000034d0| 30 2e 30 29 20 3e 20 33 | 30 2e 30 29 0a 09 20 20 |0.0) > 3|0.0).. |
|000034e0| 63 6c 6f 73 65 5f 63 6f | 6e 6e 65 63 74 69 6f 6e |close_co|nnection|
|000034f0| 28 69 29 3b 20 20 20 2f | 2a 20 74 68 69 73 20 63 |(i); /|* this c|
|00003500| 6f 6e 6e 20 61 73 6b 65 | 64 20 66 6f 72 20 73 6f |onn aske|d for so|
|00003510| 6d 65 74 68 69 6e 67 20 | 33 30 20 6d 69 6e 75 74 |mething |30 minut|
|00003520| 65 73 0a 09 09 09 09 20 | 20 20 20 61 67 6f 20 61 |es..... | ago a|
|00003530| 6e 64 20 73 74 69 6c 6c | 20 68 61 73 6e 27 74 20 |nd still| hasn't |
|00003540| 67 6f 74 74 65 6e 20 69 | 74 2e 2e 2e 20 2a 2f 0a |gotten i|t... */.|
|00003550| 20 20 20 20 20 20 7d 20 | 0a 20 20 20 20 20 20 69 | } |. i|
|00003560| 66 20 28 50 45 4e 44 49 | 4e 47 5f 53 48 55 54 44 |f (PENDI|NG_SHUTD|
|00003570| 4f 57 4e 29 0a 09 69 66 | 20 20 28 28 28 73 65 63 |OWN)..if| (((sec|
|00003580| 73 20 2d 20 63 6f 6e 6e | 2d 3e 63 5f 6c 61 73 74 |s - conn|->c_last|
|00003590| 29 20 2f 20 36 30 2e 30 | 29 20 3c 20 6d 61 78 5f |) / 60.0|) < max_|
|000035a0| 73 74 61 6c 65 5f 74 69 | 6d 65 29 0a 09 20 20 64 |stale_ti|me).. d|
|000035b0| 6f 5f 73 68 75 74 64 6f | 77 6e 20 3d 20 46 41 4c |o_shutdo|wn = FAL|
|000035c0| 53 45 3b 0a 20 20 20 20 | 20 20 69 66 20 28 28 28 |SE;. | if (((|
|000035d0| 73 65 63 73 20 2d 20 63 | 6f 6e 6e 2d 3e 63 5f 6c |secs - c|onn->c_l|
|000035e0| 61 73 74 29 20 2f 20 36 | 30 2e 30 29 20 3e 20 37 |ast) / 6|0.0) > 7|
|000035f0| 30 30 2e 30 29 0a 09 20 | 63 6c 6f 73 65 5f 63 6f |00.0).. |close_co|
|00003600| 6e 6e 65 63 74 69 6f 6e | 28 69 29 3b 20 20 2f 2a |nnection|(i); /*|
|00003610| 20 63 6c 6f 73 65 20 63 | 6f 6e 6e 65 63 74 69 6f | close c|onnectio|
|00003620| 6e 73 20 77 68 69 63 68 | 0a 09 09 09 09 20 20 74 |ns which|..... t|
|00003630| 69 6d 65 64 20 6f 75 74 | 20 2a 2f 0a 20 20 20 20 |imed out| */. |
|00003640| 7d 0a 20 20 20 20 0a 20 | 20 20 20 69 66 20 28 50 |}. . | if (P|
|00003650| 45 4e 44 49 4e 47 5f 53 | 48 55 54 44 4f 57 4e 20 |ENDING_S|HUTDOWN |
|00003660| 26 26 20 64 6f 5f 73 68 | 75 74 64 6f 77 6e 29 0a |&& do_sh|utdown).|
|00003670| 20 20 20 20 20 20 73 65 | 72 76 65 72 5f 73 68 75 | se|rver_shu|
|00003680| 74 64 6f 77 6e 28 29 3b | 0a 20 20 20 20 69 66 20 |tdown();|. if |
|00003690| 28 73 68 6f 77 5f 63 6f | 6e 6e 65 63 74 20 26 26 |(show_co|nnect &&|
|000036a0| 20 64 65 62 75 67 29 20 | 7b 0a 20 20 20 20 20 20 | debug) |{. |
|000036b0| 69 66 20 28 6e 75 6d 5f | 63 6f 6e 6e 65 63 74 69 |if (num_|connecti|
|000036c0| 6f 6e 29 20 7b 0a 09 70 | 72 69 6e 74 66 28 22 5c |on) {..p|rintf("\|
|000036d0| 6e 25 64 20 63 6f 6e 6e | 65 63 74 69 6f 6e 25 73 |n%d conn|ection%s|
|000036e0| 20 63 75 72 72 65 6e 74 | 6c 79 20 65 73 74 61 62 | current|ly estab|
|000036f0| 6c 69 73 68 65 64 2e 5c | 6e 22 2c 0a 09 20 20 20 |lished.\|n",.. |
|00003700| 20 20 20 20 6e 75 6d 5f | 63 6f 6e 6e 65 63 74 69 | num_|connecti|
|00003710| 6f 6e 2c 20 6e 75 6d 5f | 63 6f 6e 6e 65 63 74 69 |on, num_|connecti|
|00003720| 6f 6e 20 3d 3d 20 31 20 | 3f 20 22 22 20 3a 20 22 |on == 1 |? "" : "|
|00003730| 73 22 29 3b 0a 09 66 66 | 6c 75 73 68 28 73 74 64 |s");..ff|lush(std|
|00003740| 6f 75 74 29 3b 0a 20 20 | 20 20 20 20 7d 0a 20 20 |out);. | }. |
|00003750| 20 20 20 20 2f 2a 20 20 | 20 20 20 20 65 6c 73 65 | /* | else|
|00003760| 0a 09 20 20 20 20 20 20 | 70 75 74 73 28 22 20 4e |.. |puts(" N|
|00003770| 6f 6e 65 22 29 3b 20 2a | 2f 0a 20 20 20 20 7d 0a |one"); *|/. }.|
|00003780| 20 20 20 20 69 66 20 28 | 64 65 62 75 67 29 20 7b | if (|debug) {|
|00003790| 0a 20 20 20 20 20 20 69 | 66 20 28 41 63 74 69 76 |. i|f (Activ|
|000037a0| 65 4a 6f 62 73 29 0a 09 | 70 72 69 6e 74 66 28 22 |eJobs)..|printf("|
|000037b0| 25 73 20 66 6f 72 20 61 | 63 74 69 76 69 74 79 2e |%s for a|ctivity.|
|000037c0| 2e 2e 22 2c 0a 09 20 20 | 20 20 20 20 20 41 63 74 |..",.. | Act|
|000037d0| 69 76 65 4a 6f 62 73 20 | 3f 20 22 43 68 65 63 6b |iveJobs |? "Check|
|000037e0| 69 6e 67 22 20 3a 20 22 | 57 61 69 74 69 6e 67 22 |ing" : "|Waiting"|
|000037f0| 29 3b 0a 20 20 20 20 20 | 20 69 66 20 28 41 63 74 |);. | if (Act|
|00003800| 69 76 65 4a 6f 62 73 29 | 0a 09 70 72 69 6e 74 66 |iveJobs)|..printf|
|00003810| 28 22 28 25 64 20 61 73 | 6c 65 65 70 29 2e 2e 2e |("(%d as|leep)...|
|00003820| 22 2c 20 41 63 74 69 76 | 65 4a 6f 62 73 29 3b 0a |", Activ|eJobs);.|
|00003830| 20 20 20 20 20 20 66 66 | 6c 75 73 68 28 73 74 64 | ff|lush(std|
|00003840| 6f 75 74 29 3b 0a 20 20 | 20 20 7d 0a 20 20 20 20 |out);. | }. |
|00003850| 73 68 6f 77 5f 63 6f 6e | 6e 65 63 74 20 3d 20 30 |show_con|nect = 0|
|00003860| 3b 0a 20 20 20 20 0a 20 | 20 20 20 0a 20 20 20 20 |;. . | . |
|00003870| 61 63 74 69 76 65 5f 73 | 6f 63 6b 73 20 3d 20 73 |active_s|ocks = s|
|00003880| 65 6c 65 63 74 28 46 44 | 5f 53 45 54 53 49 5a 45 |elect(FD|_SETSIZE|
|00003890| 2c 26 72 65 61 64 5f 66 | 64 73 2c 20 26 77 72 69 |,&read_f|ds, &wri|
|000038a0| 74 65 5f 66 64 73 2c 20 | 0a 09 09 09 20 20 26 65 |te_fds, |.... &e|
|000038b0| 78 63 65 70 74 5f 66 64 | 73 2c 0a 09 09 09 20 20 |xcept_fd|s,.... |
|000038c0| 42 4c 4f 43 4b 29 3b 0a | 20 20 20 20 0a 20 20 20 |BLOCK);.| . |
|000038d0| 20 69 66 20 28 61 63 74 | 69 76 65 5f 73 6f 63 6b | if (act|ive_sock|
|000038e0| 73 20 3c 20 30 29 20 7b | 0a 20 20 20 20 20 20 69 |s < 0) {|. i|
|000038f0| 66 20 28 65 72 72 6e 6f | 20 21 3d 20 45 49 4e 54 |f (errno| != EINT|
|00003900| 52 29 0a 09 70 65 72 72 | 6f 72 28 22 73 65 6c 65 |R)..perr|or("sele|
|00003910| 63 74 22 29 3b 0a 20 20 | 20 20 20 20 63 6f 6e 74 |ct");. | cont|
|00003920| 69 6e 75 65 3b 0a 20 20 | 20 20 7d 0a 20 20 20 20 |inue;. | }. |
|00003930| 69 66 20 28 64 65 62 75 | 67 29 20 7b 0a 20 20 20 |if (debu|g) {. |
|00003940| 20 20 20 69 66 20 28 21 | 61 63 74 69 76 65 5f 73 | if (!|active_s|
|00003950| 6f 63 6b 73 20 26 26 20 | 41 63 74 69 76 65 4a 6f |ocks && |ActiveJo|
|00003960| 62 73 29 20 7b 0a 09 70 | 72 69 6e 74 66 28 22 6e |bs) {..p|rintf("n|
|00003970| 6f 6e 65 2e 2e 2e 63 6f | 6e 74 69 6e 75 69 6e 67 |one...co|ntinuing|
|00003980| 20 6f 75 72 20 25 64 20 | 61 63 74 69 76 65 20 70 | our %d |active p|
|00003990| 72 6f 63 65 73 73 65 73 | 2e 2e 2e 5c 6e 22 2c 0a |rocesses|...\n",.|
|000039a0| 09 20 20 20 20 20 20 20 | 41 63 74 69 76 65 4a 6f |. |ActiveJo|
|000039b0| 62 73 29 3b 0a 09 63 6f | 6e 74 69 6e 75 65 3b 0a |bs);..co|ntinue;.|
|000039c0| 20 20 20 20 20 20 7d 0a | 20 20 20 20 20 20 0a 20 | }.| . |
|000039d0| 20 20 20 20 20 0a 20 20 | 20 20 20 20 70 72 69 6e | . | prin|
|000039e0| 74 66 28 22 25 64 20 73 | 6f 63 6b 65 74 25 73 20 |tf("%d s|ocket%s |
|000039f0| 72 65 70 6f 72 74 65 64 | 20 77 69 74 68 20 6e 65 |reported| with ne|
|00003a00| 77 20 61 63 74 69 76 69 | 74 79 2e 5c 6e 22 2c 0a |w activi|ty.\n",.|
|00003a10| 09 20 20 20 20 20 61 63 | 74 69 76 65 5f 73 6f 63 |. ac|tive_soc|
|00003a20| 6b 73 2c 20 61 63 74 69 | 76 65 5f 73 6f 63 6b 73 |ks, acti|ve_socks|
|00003a30| 20 3d 3d 20 31 20 3f 20 | 22 22 20 3a 20 22 73 22 | == 1 ? |"" : "s"|
|00003a40| 29 3b 0a 20 20 20 20 20 | 20 66 66 6c 75 73 68 28 |);. | fflush(|
|00003a50| 73 74 64 6f 75 74 29 3b | 0a 20 20 20 20 7d 0a 20 |stdout);|. }. |
|00003a60| 20 20 20 68 61 6e 64 6c | 65 64 20 3d 20 30 3b 0a | handl|ed = 0;.|
|00003a70| 20 20 20 20 0a 20 20 20 | 20 2f 2a 0a 20 20 20 20 | . | /*. |
|00003a80| 20 2a 20 46 69 72 73 74 | 2c 20 73 65 65 20 69 66 | * First|, see if|
|00003a90| 20 77 65 20 63 61 6e 20 | 65 73 74 61 62 6c 69 73 | we can |establis|
|00003aa0| 68 20 61 6e 79 20 6e 65 | 77 20 63 6f 6e 6e 65 63 |h any ne|w connec|
|00003ab0| 74 69 6f 6e 73 2e 20 54 | 61 6b 65 73 0a 20 20 20 |tions. T|akes. |
|00003ac0| 20 20 2a 20 6f 6e 6c 79 | 20 66 69 72 73 74 20 6f | * only| first o|
|00003ad0| 6e 65 20 6f 66 66 20 71 | 75 65 75 65 20 65 76 65 |ne off q|ueue eve|
|00003ae0| 6e 20 69 66 20 74 68 65 | 72 65 20 61 72 65 20 6d |n if the|re are m|
|00003af0| 6f 72 65 2e 20 0a 20 20 | 20 20 20 2a 2f 0a 20 20 |ore. . | */. |
|00003b00| 20 20 0a 20 20 20 20 69 | 66 20 28 73 6f 63 6b 5f | . i|f (sock_|
|00003b10| 72 65 61 64 61 62 6c 65 | 28 6c 69 73 74 65 6e 5f |readable|(listen_|
|00003b20| 73 6f 63 6b 29 29 0a 20 | 20 20 20 20 20 7b 0a 09 |sock)). | {..|
|00003b30| 6d 61 6b 65 5f 6e 65 77 | 5f 63 6f 6e 6e 65 63 74 |make_new|_connect|
|00003b40| 69 6f 6e 28 6c 69 73 74 | 65 6e 5f 73 6f 63 6b 29 |ion(list|en_sock)|
|00003b50| 3b 0a 09 68 61 6e 64 6c | 65 64 2b 2b 3b 0a 09 73 |;..handl|ed++;..s|
|00003b60| 68 6f 77 5f 63 6f 6e 6e | 65 63 74 2b 2b 3b 0a 20 |how_conn|ect++;. |
|00003b70| 20 20 20 20 20 7d 0a 20 | 20 20 20 0a 20 20 20 20 | }. | . |
|00003b80| 2f 2a 0a 20 20 20 20 20 | 2a 20 4e 6f 77 20 68 61 |/*. |* Now ha|
|00003b90| 6e 64 6c 65 20 72 65 71 | 75 65 73 74 73 20 66 72 |ndle req|uests fr|
|00003ba0| 6f 6d 20 61 6c 6c 20 63 | 6f 6e 6e 65 63 74 69 6f |om all c|onnectio|
|00003bb0| 6e 73 20 74 68 61 74 20 | 68 61 76 65 20 73 65 6e |ns that |have sen|
|00003bc0| 74 0a 20 20 20 20 20 2a | 20 74 68 65 6d 2e 20 0a |t. *| them. .|
|00003bd0| 20 20 20 20 20 2a 2f 0a | 0a 20 20 20 20 74 6f 64 | */.|. tod|
|00003be0| 61 79 73 64 61 74 65 20 | 3d 20 74 69 6d 65 28 30 |aysdate |= time(0|
|00003bf0| 29 20 2f 20 41 44 41 59 | 3b 20 20 2f 2a 20 6f 75 |) / ADAY|; /* ou|
|00003c00| 74 73 69 64 65 20 6c 6f | 6f 70 3b 20 75 73 65 64 |tside lo|op; used|
|00003c10| 20 62 79 20 6f 74 68 65 | 72 20 6d 6f 64 75 6c 65 | by othe|r module|
|00003c20| 73 20 2a 2f 0a 0a 20 20 | 20 20 66 6f 72 20 28 69 |s */.. | for (i|
|00003c30| 20 3d 20 30 3b 20 69 20 | 3c 20 46 44 5f 53 45 54 | = 0; i |< FD_SET|
|00003c40| 53 49 5a 45 3b 20 69 2b | 2b 29 20 7b 0a 20 20 20 |SIZE; i+|+) {. |
|00003c50| 20 20 20 69 66 20 28 21 | 63 6f 6e 6e 5f 65 73 74 | if (!|conn_est|
|00003c60| 61 62 6c 69 73 68 65 64 | 28 69 29 29 0a 09 63 6f |ablished|(i))..co|
|00003c70| 6e 74 69 6e 75 65 3b 0a | 20 20 20 20 20 20 69 66 |ntinue;.| if|
|00003c80| 20 28 63 6f 6e 6e 5f 74 | 69 6d 65 64 6f 75 74 28 | (conn_t|imedout(|
|00003c90| 69 29 29 20 7b 0a 09 69 | 66 20 28 63 6f 6e 6e 5f |i)) {..i|f (conn_|
|00003ca0| 72 65 61 64 61 62 6c 65 | 28 69 29 29 0a 09 20 20 |readable|(i)).. |
|00003cb0| 68 61 6e 64 6c 65 64 2b | 2b 3b 0a 09 09 63 6c 6f |handled+|+;...clo|
|00003cc0| 73 65 5f 63 6f 6e 6e 65 | 63 74 69 6f 6e 28 69 29 |se_conne|ction(i)|
|00003cd0| 2c 20 73 68 6f 77 5f 63 | 6f 6e 6e 65 63 74 2b 2b |, show_c|onnect++|
|00003ce0| 3b 0a 09 63 6f 6e 74 69 | 6e 75 65 3b 0a 20 20 20 |;..conti|nue;. |
|00003cf0| 20 20 20 7d 0a 20 20 20 | 20 20 20 69 66 20 28 63 | }. | if (c|
|00003d00| 6f 6e 6e 5f 65 78 63 65 | 70 74 28 69 29 29 20 7b |onn_exce|pt(i)) {|
|00003d10| 0a 09 70 72 69 6e 74 66 | 28 22 45 78 63 65 70 74 |..printf|("Except|
|00003d20| 69 6f 6e 61 6c 20 63 6f | 6e 64 69 74 69 6f 6e 20 |ional co|ndition |
|00003d30| 6f 6e 20 73 6f 63 6b 65 | 74 20 25 64 2c 20 63 6c |on socke|t %d, cl|
|00003d40| 6f 73 69 6e 67 20 63 6f | 6e 6e 65 63 74 69 6f 6e |osing co|nnection|
|00003d50| 2e 5c 6e 22 2c 20 69 29 | 3b 0a 09 66 66 6c 75 73 |.\n", i)|;..fflus|
|00003d60| 68 28 73 74 64 6f 75 74 | 29 3b 0a 09 68 61 6e 64 |h(stdout|);..hand|
|00003d70| 6c 65 64 2b 2b 3b 0a 09 | 63 6c 6f 73 65 5f 63 6f |led++;..|close_co|
|00003d80| 6e 6e 65 63 74 69 6f 6e | 28 69 29 3b 0a 09 63 6f |nnection|(i);..co|
|00003d90| 6e 74 69 6e 75 65 3b 0a | 20 20 20 20 20 20 7d 0a |ntinue;.| }.|
|00003da0| 20 20 20 20 20 20 0a 20 | 20 20 20 20 20 69 66 20 | . | if |
|00003db0| 28 63 6f 6e 6e 5f 77 61 | 69 74 5f 72 65 63 76 28 |(conn_wa|it_recv(|
|00003dc0| 69 29 29 7b 20 2f 2a 20 | 69 66 20 77 65 27 72 65 |i)){ /* |if we're|
|00003dd0| 20 69 6e 20 74 68 65 20 | 6d 69 64 64 6c 65 20 6f | in the |middle o|
|00003de0| 66 0a 09 09 09 09 20 67 | 65 74 74 69 6e 67 20 61 |f..... g|etting a|
|00003df0| 20 66 69 6c 65 20 2a 2f | 0a 09 6e 69 6f 5f 72 65 | file */|..nio_re|
|00003e00| 63 5f 6d 6f 72 65 28 63 | 6f 6e 6e 74 61 62 5b 69 |c_more(c|onntab[i|
|00003e10| 5d 2e 63 5f 72 65 63 70 | 74 72 29 3b 0a 09 68 61 |].c_recp|tr);..ha|
|00003e20| 6e 64 6c 65 64 2b 2b 3b | 0a 09 63 6f 6e 74 69 6e |ndled++;|..contin|
|00003e30| 75 65 3b 0a 20 20 20 20 | 20 20 7d 0a 20 20 20 20 |ue;. | }. |
|00003e40| 20 20 65 6c 73 65 20 69 | 66 20 28 63 6f 6e 6e 5f | else i|f (conn_|
|00003e50| 77 72 69 74 65 61 62 6c | 65 28 69 29 29 20 0a 09 |writeabl|e(i)) ..|
|00003e60| 7b 20 2f 2a 20 66 69 6e | 69 73 68 20 77 72 69 74 |{ /* fin|ish writ|
|00003e70| 69 6e 67 20 2a 2f 0a 09 | 20 20 68 61 6e 64 6c 65 |ing */..| handle|
|00003e80| 64 2b 2b 3b 0a 09 20 20 | 73 65 6e 64 5f 6d 6f 72 |d++;.. |send_mor|
|00003e90| 65 28 63 6f 6e 6e 74 61 | 62 5b 69 5d 2e 63 5f 70 |e(connta|b[i].c_p|
|00003ea0| 74 72 29 3b 0a 09 7d 0a | 20 20 20 20 20 20 65 6c |tr);..}.| el|
|00003eb0| 73 65 20 69 66 20 28 63 | 6f 6e 6e 5f 72 65 61 64 |se if (c|onn_read|
|00003ec0| 61 62 6c 65 28 69 29 29 | 0a 09 7b 0a 09 20 20 68 |able(i))|..{.. h|
|00003ed0| 61 6e 64 6c 65 64 2b 2b | 3b 0a 0a 09 20 20 69 66 |andled++|;... if|
|00003ee0| 20 28 68 64 6c 5f 63 6f | 6e 6e 65 63 74 28 69 29 | (hdl_co|nnect(i)|
|00003ef0| 20 7c 7c 20 63 6f 6e 6e | 74 61 62 5b 69 5d 2e 63 | || conn|tab[i].c|
|00003f00| 5f 74 72 61 6e 73 5f 63 | 6e 74 20 3e 20 4d 41 58 |_trans_c|nt > MAX|
|00003f10| 5f 54 52 41 4e 53 29 0a | 09 20 20 20 20 7b 0a 09 |_TRANS).|. {..|
|00003f20| 20 20 20 20 63 6c 6f 73 | 65 5f 63 6f 6e 6e 65 63 | clos|e_connec|
|00003f30| 74 69 6f 6e 28 69 29 2c | 20 73 68 6f 77 5f 63 6f |tion(i),| show_co|
|00003f40| 6e 6e 65 63 74 2b 2b 3b | 0a 09 20 20 20 20 69 66 |nnect++;|.. if|
|00003f50| 20 28 63 6f 6e 6e 74 61 | 62 5b 69 5d 2e 63 5f 74 | (connta|b[i].c_t|
|00003f60| 72 61 6e 73 5f 63 6e 74 | 20 3e 20 4d 41 58 5f 54 |rans_cnt| > MAX_T|
|00003f70| 52 41 4e 53 29 20 7b 0a | 09 20 20 20 20 20 20 73 |RANS) {.|. s|
|00003f80| 70 72 69 6e 74 66 28 6c | 69 6e 65 2c 22 4d 41 58 |printf(l|ine,"MAX|
|00003f90| 20 54 52 41 4e 53 20 52 | 45 41 43 48 45 44 2e 2e | TRANS R|EACHED..|
|00003fa0| 2e 20 63 6c 6f 73 69 6e | 67 20 73 6f 63 6b 20 25 |. closin|g sock %|
|00003fb0| 64 20 2d 20 25 73 5c 6e | 22 2c 0a 09 09 20 20 20 |d - %s\n|",... |
|00003fc0| 20 20 20 63 6f 6e 6e 74 | 61 62 5b 69 5d 2e 63 5f | connt|ab[i].c_|
|00003fd0| 73 6f 63 6b 65 74 2c 63 | 6f 6e 6e 74 61 62 5b 69 |socket,c|onntab[i|
|00003fe0| 5d 2e 63 5f 68 6f 73 74 | 6e 61 6d 65 29 3b 0a 09 |].c_host|name);..|
|00003ff0| 20 20 20 20 20 20 6c 6f | 67 5f 73 65 73 73 69 6f | lo|g_sessio|
|00004000| 6e 28 6c 69 6e 65 29 3b | 0a 09 20 20 20 20 7d 0a |n(line);|.. }.|
|00004010| 09 20 20 7d 0a 09 20 20 | 63 6f 6e 74 69 6e 75 65 |. }.. |continue|
|00004020| 3b 0a 09 7d 0a 20 20 20 | 20 7d 0a 20 20 20 20 0a |;..}. | }. .|
|00004030| 20 20 20 20 2f 2a 0a 20 | 20 20 20 20 2a 20 57 65 | /*. | * We|
|00004040| 20 68 61 76 65 20 61 20 | 76 65 72 79 20 6d 61 6a | have a |very maj|
|00004050| 6f 72 20 70 72 6f 62 6c | 65 6d 20 69 66 20 77 65 |or probl|em if we|
|00004060| 20 74 68 6f 75 67 68 74 | 20 77 65 20 6e 65 65 64 | thought| we need|
|00004070| 65 64 20 74 6f 20 64 6f | 0a 20 20 20 20 20 2a 20 |ed to do|. * |
|00004080| 73 6f 6d 65 74 68 69 6e | 67 2c 20 61 6e 64 20 6e |somethin|g, and n|
|00004090| 6f 74 68 69 6e 67 20 77 | 61 73 20 64 6f 6e 65 2c |othing w|as done,|
|000040a0| 20 63 61 75 73 65 20 74 | 68 69 73 20 63 61 6e 20 | cause t|his can |
|000040b0| 6d 65 61 6e 20 77 65 27 | 72 65 0a 20 20 20 20 20 |mean we'|re. |
|000040c0| 2a 20 68 65 61 64 65 64 | 20 69 6e 74 6f 20 61 6e |* headed| into an|
|000040d0| 20 69 6e 66 69 6e 74 65 | 20 6c 6f 6f 70 2e 20 20 | infinte| loop. |
|000040e0| 53 6f 20 77 65 20 63 6c | 6f 73 65 20 65 76 65 72 |So we cl|ose ever|
|000040f0| 79 6f 6e 65 20 6f 66 66 | 20 69 66 0a 20 20 20 20 |yone off| if. |
|00004100| 20 2a 20 74 68 69 73 20 | 68 61 70 70 65 6e 73 20 | * this |happens |
|00004110| 28 61 6c 74 68 6f 75 67 | 68 20 69 74 20 6e 65 76 |(althoug|h it nev|
|00004120| 65 72 20 73 68 6f 75 6c | 64 2e 2e 2e 29 20 0a 20 |er shoul|d...) . |
|00004130| 20 20 20 20 2a 2f 0a 20 | 20 20 20 0a 20 20 20 20 | */. | . |
|00004140| 69 66 20 28 21 68 61 6e | 64 6c 65 64 29 20 7b 0a |if (!han|dled) {.|
|00004150| 20 20 20 20 20 20 66 70 | 72 69 6e 74 66 28 73 74 | fp|rintf(st|
|00004160| 64 65 72 72 2c 20 22 54 | 65 63 68 49 6e 66 6f 20 |derr, "T|echInfo |
|00004170| 73 65 72 76 65 72 3a 20 | 56 65 72 79 20 6d 61 6a |server: |Very maj|
|00004180| 6f 72 20 63 6c 69 65 6e | 74 20 70 6c 65 78 69 6e |or clien|t plexin|
|00004190| 67 20 70 72 6f 62 6c 65 | 6d 2e 5c 6e 22 29 3b 0a |g proble|m.\n");.|
|000041a0| 20 20 20 20 20 20 66 6f | 72 20 28 69 20 3d 20 30 | fo|r (i = 0|
|000041b0| 3b 20 69 20 3c 20 46 44 | 5f 53 45 54 53 49 5a 45 |; i < FD|_SETSIZE|
|000041c0| 3b 20 69 2b 2b 29 0a 09 | 69 66 20 28 63 6f 6e 6e |; i++)..|if (conn|
|000041d0| 5f 65 73 74 61 62 6c 69 | 73 68 65 64 28 69 29 29 |_establi|shed(i))|
|000041e0| 0a 09 20 20 63 6c 6f 73 | 65 5f 63 6f 6e 6e 65 63 |.. clos|e_connec|
|000041f0| 74 69 6f 6e 28 69 29 3b | 0a 20 20 20 20 7d 0a 20 |tion(i);|. }. |
|00004200| 20 7d 0a 7d 0a 0a 76 6f | 69 64 0a 62 72 6f 6b 65 | }.}..vo|id.broke|
|00004210| 6e 5f 70 69 70 65 28 29 | 0a 7b 0a 09 70 75 74 73 |n_pipe()|.{..puts|
|00004220| 28 22 53 49 47 50 49 50 | 45 20 2d 20 4e 6f 20 6f |("SIGPIP|E - No o|
|00004230| 6e 65 20 74 6f 20 72 65 | 61 64 20 6f 75 72 20 77 |ne to re|ad our w|
|00004240| 72 69 74 65 2e 22 29 3b | 0a 09 63 6c 6f 73 65 5f |rite.");|..close_|
|00004250| 63 6f 6e 6e 65 63 74 69 | 6f 6e 28 69 29 3b 0a 7d |connecti|on(i);.}|
|00004260| 0a 0a 6d 61 69 6e 28 69 | 6e 74 20 61 72 67 63 2c |..main(i|nt argc,|
|00004270| 20 63 68 61 72 20 2a 2a | 61 72 67 76 29 0a 7b 0a | char **|argv).{.|
|00004280| 0a 09 65 78 74 65 72 6e | 20 69 6e 74 09 6d 65 6e |..extern| int.men|
|00004290| 75 3b 0a 09 65 78 74 65 | 72 6e 20 69 6e 74 09 64 |u;..exte|rn int.d|
|000042a0| 69 73 70 74 79 70 65 3b | 0a 09 69 6e 74 20 70 69 |isptype;|..int pi|
|000042b0| 70 73 5f 70 6f 72 74 20 | 3d 20 50 49 50 53 5f 50 |ps_port |= PIPS_P|
|000042c0| 4f 52 54 3b 0a 0a 09 63 | 68 61 72 20 63 3b 0a 09 |ORT;...c|har c;..|
|000042d0| 69 6e 74 20 65 72 72 6f | 72 66 6c 61 67 20 3d 20 |int erro|rflag = |
|000042e0| 30 2c 20 74 65 6d 70 5f | 70 6f 72 74 20 3d 20 30 |0, temp_|port = 0|
|000042f0| 3b 0a 09 65 78 74 65 72 | 6e 20 69 6e 74 20 6f 70 |;..exter|n int op|
|00004300| 74 69 6e 64 3b 0a 09 65 | 78 74 65 72 6e 20 63 68 |tind;..e|xtern ch|
|00004310| 61 72 20 2a 6f 70 74 61 | 72 67 3b 0a 0a 09 0a 09 |ar *opta|rg;.....|
|00004320| 77 68 69 6c 65 20 28 28 | 63 20 3d 20 67 65 74 6f |while ((|c = geto|
|00004330| 70 74 28 61 72 67 63 2c | 20 61 72 67 76 2c 20 22 |pt(argc,| argv, "|
|00004340| 64 70 3a 22 29 29 20 21 | 3d 20 45 4f 46 29 0a 09 |dp:")) !|= EOF)..|
|00004350| 20 20 73 77 69 74 63 68 | 20 28 63 29 20 7b 0a 09 | switch| (c) {..|
|00004360| 20 20 63 61 73 65 20 27 | 64 27 3a 0a 09 20 20 20 | case '|d':.. |
|00004370| 20 64 65 62 75 67 2b 2b | 3b 0a 09 20 20 20 20 62 | debug++|;.. b|
|00004380| 72 65 61 6b 3b 0a 09 20 | 20 63 61 73 65 20 27 70 |reak;.. | case 'p|
|00004390| 27 3a 0a 09 20 20 20 20 | 69 66 20 28 6f 70 74 61 |':.. |if (opta|
|000043a0| 72 67 29 09 20 20 20 20 | 20 20 0a 09 20 20 20 20 |rg). | .. |
|000043b0| 20 20 74 65 6d 70 5f 70 | 6f 72 74 20 3d 20 61 74 | temp_p|ort = at|
|000043c0| 6f 69 28 6f 70 74 61 72 | 67 29 3b 0a 09 20 20 20 |oi(optar|g);.. |
|000043d0| 20 62 72 65 61 6b 3b 0a | 09 20 20 64 65 66 61 75 | break;.|. defau|
|000043e0| 6c 74 3a 0a 09 20 20 20 | 20 65 72 72 6f 72 66 6c |lt:.. | errorfl|
|000043f0| 61 67 2b 2b 3b 0a 09 20 | 20 7d 0a 09 69 66 20 28 |ag++;.. | }..if (|
|00004400| 65 72 72 6f 72 66 6c 61 | 67 29 0a 09 20 20 7b 0a |errorfla|g).. {.|
|00004410| 09 20 20 20 20 70 72 69 | 6e 74 66 28 22 55 73 61 |. pri|ntf("Usa|
|00004420| 67 65 3a 20 25 73 20 5b | 2d 70 20 70 6f 72 74 5d |ge: %s [|-p port]|
|00004430| 20 5b 2d 64 5d 5c 6e 22 | 2c 20 61 72 67 76 5b 30 | [-d]\n"|, argv[0|
|00004440| 5d 29 3b 0a 09 20 20 20 | 20 65 78 69 74 28 31 29 |]);.. | exit(1)|
|00004450| 3b 0a 09 20 20 7d 0a 0a | 09 69 66 20 28 74 65 6d |;.. }..|.if (tem|
|00004460| 70 5f 70 6f 72 74 29 0a | 09 20 20 69 66 20 28 74 |p_port).|. if (t|
|00004470| 65 6d 70 5f 70 6f 72 74 | 20 3e 20 31 30 30 30 29 |emp_port| > 1000)|
|00004480| 0a 09 20 20 20 20 70 69 | 70 73 5f 70 6f 72 74 20 |.. pi|ps_port |
|00004490| 3d 20 74 65 6d 70 5f 70 | 6f 72 74 3b 0a 09 20 20 |= temp_p|ort;.. |
|000044a0| 65 6c 73 65 20 0a 09 20 | 20 20 20 7b 0a 09 20 20 |else .. | {.. |
|000044b0| 20 20 20 20 70 75 74 73 | 28 22 4d 75 73 74 20 75 | puts|("Must u|
|000044c0| 73 65 20 61 20 70 6f 72 | 74 20 6e 75 6d 62 65 72 |se a por|t number|
|000044d0| 20 67 72 65 61 74 65 72 | 20 74 68 61 6e 20 31 30 | greater| than 10|
|000044e0| 30 30 22 29 3b 0a 09 20 | 20 20 20 20 20 65 78 69 |00");.. | exi|
|000044f0| 74 28 31 29 3b 0a 09 20 | 20 20 20 7d 0a 09 0a 0a |t(1);.. | }....|
|00004500| 20 20 09 6d 65 6e 75 20 | 3d 20 4e 4f 4d 45 4e 55 | .menu |= NOMENU|
|00004510| 3b 0a 09 64 69 73 70 74 | 79 70 65 20 3d 20 53 49 |;..dispt|ype = SI|
|00004520| 4d 50 4c 45 3b 0a 09 73 | 65 74 75 69 64 28 53 45 |MPLE;..s|etuid(SE|
|00004530| 52 56 45 52 5f 55 49 44 | 29 3b 20 2f 2a 20 74 69 |RVER_UID|); /* ti|
|00004540| 5f 73 65 72 76 65 20 2a | 2f 0a 09 70 72 69 6e 74 |_serve *|/..print|
|00004550| 66 28 22 55 69 64 20 73 | 65 74 20 74 6f 20 25 64 |f("Uid s|et to %d|
|00004560| 5c 6e 22 2c 67 65 74 75 | 69 64 28 29 29 3b 0a 09 |\n",getu|id());..|
|00004570| 69 66 20 28 61 63 63 65 | 73 73 28 50 52 4f 56 5f |if (acce|ss(PROV_|
|00004580| 46 49 4c 45 2c 20 46 5f | 4f 4b 29 29 20 7b 0a 09 |FILE, F_|OK)) {..|
|00004590| 09 70 75 74 73 28 22 43 | 6f 75 6c 64 20 6e 6f 74 |.puts("C|ould not|
|000045a0| 20 66 69 6e 64 20 74 68 | 65 20 70 72 6f 76 69 64 | find th|e provid|
|000045b0| 65 72 20 66 69 6c 65 22 | 29 3b 0a 09 09 65 78 69 |er file"|);...exi|
|000045c0| 74 28 31 29 3b 0a 09 7d | 0a 09 69 66 20 28 61 63 |t(1);..}|..if (ac|
|000045d0| 63 65 73 73 28 41 44 4d | 49 4e 5f 46 49 4c 45 2c |cess(ADM|IN_FILE,|
|000045e0| 20 46 5f 4f 4b 29 29 20 | 7b 0a 09 09 70 75 74 73 | F_OK)) |{...puts|
|000045f0| 28 22 43 6f 75 6c 64 20 | 6e 6f 74 20 66 69 6e 64 |("Could |not find|
|00004600| 20 74 68 65 20 61 64 6d | 69 6e 20 66 69 6c 65 22 | the adm|in file"|
|00004610| 29 3b 0a 09 09 65 78 69 | 74 28 31 29 3b 09 0a 09 |);...exi|t(1);...|
|00004620| 20 20 20 20 20 20 7d 0a | 09 69 66 20 28 61 63 63 | }.|.if (acc|
|00004630| 65 73 73 28 4e 45 58 54 | 49 44 5f 46 49 4c 45 2c |ess(NEXT|ID_FILE,|
|00004640| 20 46 5f 4f 4b 29 29 20 | 7b 0a 09 09 70 75 74 73 | F_OK)) |{...puts|
|00004650| 28 22 43 6f 75 6c 64 20 | 6e 6f 74 20 66 69 6e 64 |("Could |not find|
|00004660| 20 74 68 65 20 6e 65 78 | 74 5f 69 64 20 66 69 6c | the nex|t_id fil|
|00004670| 65 22 29 3b 0a 09 09 65 | 78 69 74 28 31 29 3b 09 |e");...e|xit(1);.|
|00004680| 0a 09 20 20 20 20 20 20 | 7d 0a 09 69 66 20 28 61 |.. |}..if (a|
|00004690| 63 63 65 73 73 28 56 45 | 52 5f 46 49 4c 45 2c 20 |ccess(VE|R_FILE, |
|000046a0| 46 5f 4f 4b 29 29 20 7b | 0a 09 09 70 75 74 73 28 |F_OK)) {|...puts(|
|000046b0| 22 43 6f 75 6c 64 20 6e | 6f 74 20 66 69 6e 64 20 |"Could n|ot find |
|000046c0| 74 68 65 20 76 65 72 73 | 69 6f 6e 20 66 69 6c 65 |the vers|ion file|
|000046d0| 22 29 3b 0a 09 09 65 78 | 69 74 28 31 29 3b 09 0a |");...ex|it(1);..|
|000046e0| 09 20 20 20 20 20 20 7d | 0a 09 69 66 20 28 61 63 |. }|..if (ac|
|000046f0| 63 65 73 73 28 53 4f 55 | 52 43 45 5f 46 49 4c 45 |cess(SOU|RCE_FILE|
|00004700| 2c 20 46 5f 4f 4b 29 29 | 20 7b 0a 09 09 70 75 74 |, F_OK))| {...put|
|00004710| 73 28 22 43 6f 75 6c 64 | 20 6e 6f 74 20 66 69 6e |s("Could| not fin|
|00004720| 64 20 74 68 65 20 73 6f | 75 72 63 65 20 66 69 6c |d the so|urce fil|
|00004730| 65 22 29 3b 0a 09 09 65 | 78 69 74 28 31 29 3b 09 |e");...e|xit(1);.|
|00004740| 0a 09 20 20 20 20 20 20 | 7d 0a 09 69 66 20 28 61 |.. |}..if (a|
|00004750| 63 63 65 73 73 28 53 45 | 52 56 45 52 5f 46 49 4c |ccess(SE|RVER_FIL|
|00004760| 45 2c 20 46 5f 4f 4b 29 | 29 20 7b 0a 09 09 70 75 |E, F_OK)|) {...pu|
|00004770| 74 73 28 22 43 6f 75 6c | 64 20 6e 6f 74 20 66 69 |ts("Coul|d not fi|
|00004780| 6e 64 20 74 68 65 20 73 | 65 72 76 65 72 20 66 69 |nd the s|erver fi|
|00004790| 6c 65 22 29 3b 0a 09 09 | 65 78 69 74 28 31 29 3b |le");...|exit(1);|
|000047a0| 09 0a 09 20 20 20 20 20 | 20 7d 0a 09 66 6f 72 20 |... | }..for |
|000047b0| 28 69 20 3d 20 30 3b 20 | 69 20 3c 20 46 44 5f 53 |(i = 0; |i < FD_S|
|000047c0| 45 54 53 49 5a 45 3b 20 | 69 2b 2b 29 0a 09 09 63 |ETSIZE; |i++)...c|
|000047d0| 6f 6e 6e 74 61 62 5b 69 | 5d 2e 63 5f 73 6f 63 6b |onntab[i|].c_sock|
|000047e0| 65 74 20 3d 20 2d 31 3b | 09 0a 09 73 69 67 6e 61 |et = -1;|...signa|
|000047f0| 6c 28 53 49 47 49 4e 54 | 2c 20 73 65 72 76 65 72 |l(SIGINT|, server|
|00004800| 5f 73 68 75 74 64 6f 77 | 6e 29 3b 0a 09 73 69 67 |_shutdow|n);..sig|
|00004810| 6e 61 6c 28 53 49 47 54 | 45 52 4d 2c 20 73 65 72 |nal(SIGT|ERM, ser|
|00004820| 76 65 72 5f 73 68 75 74 | 64 6f 77 6e 29 3b 0a 09 |ver_shut|down);..|
|00004830| 73 69 67 6e 61 6c 28 53 | 49 47 43 48 4c 44 2c 20 |signal(S|IGCHLD, |
|00004840| 63 61 74 63 68 5f 63 68 | 69 6c 64 29 3b 0a 09 73 |catch_ch|ild);..s|
|00004850| 69 67 6e 61 6c 28 53 49 | 47 48 55 50 2c 20 63 61 |ignal(SI|GHUP, ca|
|00004860| 74 63 68 5f 68 75 70 29 | 3b 0a 09 53 45 52 56 45 |tch_hup)|;..SERVE|
|00004870| 52 20 3d 20 54 52 55 45 | 3b 0a 09 70 72 69 6e 74 |R = TRUE|;..print|
|00004880| 66 28 22 5c 6e 25 73 5c | 6e 22 2c 20 42 41 4e 4e |f("\n%s\|n", BANN|
|00004890| 45 52 29 3b 20 66 66 6c | 75 73 68 28 73 74 64 6f |ER); ffl|ush(stdo|
|000048a0| 75 74 29 3b 0a 09 74 69 | 6d 65 28 26 73 65 63 73 |ut);..ti|me(&secs|
|000048b0| 29 3b 0a 09 6c 6f 61 64 | 5f 6d 73 67 73 28 29 3b |);..load|_msgs();|
|000048c0| 20 2f 2a 20 6c 6f 61 64 | 20 74 68 65 20 6d 65 73 | /* load| the mes|
|000048d0| 73 61 67 65 20 6c 69 73 | 74 20 66 72 6f 6d 20 64 |sage lis|t from d|
|000048e0| 69 73 6b 20 2a 2f 0a 09 | 70 72 69 6e 74 66 28 22 |isk */..|printf("|
|000048f0| 53 74 61 72 74 65 64 20 | 25 2e 32 34 73 2c 20 70 |Started |%.24s, p|
|00004900| 69 64 20 3d 20 25 64 5c | 6e 5c 6e 22 2c 20 63 74 |id = %d\|n\n", ct|
|00004910| 69 6d 65 28 26 73 65 63 | 73 29 2c 20 67 65 74 70 |ime(&sec|s), getp|
|00004920| 69 64 28 29 29 3b 0a 09 | 66 66 6c 75 73 68 28 73 |id());..|fflush(s|
|00004930| 74 64 6f 75 74 29 3b 0a | 0a 09 6c 69 73 74 65 6e |tdout);.|..listen|
|00004940| 5f 73 6f 63 6b 20 3d 20 | 69 6e 65 74 5f 6d 61 6b |_sock = |inet_mak|
|00004950| 65 5f 6c 69 73 74 6e 65 | 72 28 70 69 70 73 5f 70 |e_listne|r(pips_p|
|00004960| 6f 72 74 29 3b 0a 09 69 | 66 20 28 6c 69 73 74 65 |ort);..i|f (liste|
|00004970| 6e 5f 73 6f 63 6b 20 3c | 20 30 29 20 7b 0a 09 09 |n_sock <| 0) {...|
|00004980| 70 75 74 73 28 22 55 6e | 61 62 6c 65 20 74 6f 20 |puts("Un|able to |
|00004990| 61 63 63 65 70 74 20 63 | 6f 6e 6e 65 63 74 69 6f |accept c|onnectio|
|000049a0| 6e 73 21 22 29 3b 0a 09 | 09 65 78 69 74 28 31 29 |ns!");..|.exit(1)|
|000049b0| 3b 0a 09 7d 0a 09 69 66 | 20 28 21 28 69 6e 74 29 |;..}..if| (!(int)|
|000049c0| 20 64 61 74 61 73 74 72 | 75 63 74 5f 6c 6f 61 64 | datastr|uct_load|
|000049d0| 28 30 29 29 20 7b 0a 09 | 09 70 75 74 73 28 22 46 |(0)) {..|.puts("F|
|000049e0| 61 74 61 6c 20 65 72 72 | 6f 72 3a 20 64 61 74 61 |atal err|or: data|
|000049f0| 73 74 72 75 63 74 5f 6c | 6f 61 64 20 66 61 69 6c |struct_l|oad fail|
|00004a00| 65 64 22 29 3b 0a 09 09 | 65 78 69 74 28 31 29 3b |ed");...|exit(1);|
|00004a10| 0a 09 7d 0a 0a 09 46 44 | 5f 5a 45 52 4f 28 26 72 |..}...FD|_ZERO(&r|
|00004a20| 65 61 64 5f 66 64 73 29 | 3b 0a 09 6c 6f 67 5f 74 |ead_fds)|;..log_t|
|00004a30| 72 61 6e 73 28 22 53 74 | 61 72 74 69 6e 67 20 73 |rans("St|arting s|
|00004a40| 65 72 76 65 72 22 29 3b | 0a 09 70 72 69 6e 74 66 |erver");|..printf|
|00004a50| 28 22 54 65 63 68 49 6e | 66 6f 20 73 65 72 76 65 |("TechIn|fo serve|
|00004a60| 72 20 72 65 61 64 79 2e | 5c 6e 22 29 3b 20 66 66 |r ready.|\n"); ff|
|00004a70| 6c 75 73 68 28 73 74 64 | 6f 75 74 29 3b 0a 09 6e |lush(std|out);..n|
|00004a80| 75 6d 5f 63 6f 6e 6e 65 | 63 74 69 6f 6e 20 3d 20 |um_conne|ction = |
|00004a90| 30 3b 0a 09 73 69 67 6e | 61 6c 28 53 49 47 50 49 |0;..sign|al(SIGPI|
|00004aa0| 50 45 2c 20 62 72 6f 6b | 65 6e 5f 70 69 70 65 29 |PE, brok|en_pipe)|
|00004ab0| 3b 0a 09 75 6d 61 73 6b | 28 30 32 32 29 3b 0a 0a |;..umask|(022);..|
|00004ac0| 09 66 66 6c 75 73 68 28 | 73 74 64 6f 75 74 29 3b |.fflush(|stdout);|
|00004ad0| 0a 09 73 65 72 76 65 72 | 5f 6c 6f 6f 70 28 29 3b |..server|_loop();|
|00004ae0| 0a 7d 0a 67 29 20 7b 0a | 09 20 20 70 72 69 6e 74 |.}.g) {.|. print|
|00004af0| 66 28 22 41 63 63 65 70 | 74 65 64 20 6e 65 77 20 |f("Accep|ted new |
|00004b00| 63 6f 6e 6e 65 63 74 69 | 6f 6e 20 74 6f 20 25 73 |connecti|on to %s|
|00004b10| 2c 20 74 68 72 75 20 70 | 6f 72 74 20 25 64 2c 20 |, thru p|ort %d, |
|00004b20| 6f 76 65 72 20 73 6f 63 | 6b 65 74 20 23 25 64 2e |over soc|ket #%d.|
|00004b30| 5c 6e 22 2c 0a 09 20 20 | 20 20 20 20 20 63 6f 6e |\n",.. | con|
|00004b40| 6e 2d 3e 63 5f 68 6f 73 | 74 6e 61 6d 65 2c 0a 09 |n->c_hos|tname,..|
|00004b50| 20 20 20 20 20 20 20 63 | 6f 6e 6e 2d 3e 63 5f 70 | c|onn->c_p|
|00004b60| 6f 72 74 6e 75 6d 2c 0a | 09 20 20 20 20 20 20 20 |ortnum,.|. |
|00004b70| 63 6f 6e 6e 2d 3e 63 5f | 73 6f 63 6b 65 74 29 3b |conn->c_|socket);|
|00004b80| 0a 09 20 20 66 66 6c 75 | 73 68 28 73 74 64 6f 75 |.. fflu|sh(stdou|
|00004b90| 74 29 3b 0a 09 7d 0a 09 | 69 66 20 28 41 4c 54 5f |t);..}..|if (ALT_|
|00004ba0| 42 41 4e 4e 45 52 29 20 | 7b 0a 09 20 20 77 72 69 |BANNER) |{.. wri|
|00004bb0| 74 65 28 63 6f 6e 6e 2d | 3e 63 5f 73 6f 63 6b 65 |te(conn-|>c_socke|
|00004bc0| 74 2c 20 61 6c 74 5f 62 | 61 6e 6e 65 72 2c 20 73 |t, alt_b|anner, s|
|00004bd0| 74 72 6c 65 6e 28 61 6c | 74 5f 62 61 6e 6e 65 72 |trlen(al|t_banner|
|00004be0| 29 29 3b 0a 09 20 20 77 | 72 69 74 65 28 63 6f 6e |));.. w|rite(con|
|00004bf0| 6e 2d 3e 63 5f 73 6f 63 | 6b 65 74 2c 20 45 4f 4d |n->c_soc|ket, EOM|
|00004c00| 76 31 2e 30 2f 74 72 61 | 6e 73 61 63 74 2e 63 00 |v1.0/tra|nsact.c.|
|00004c10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c60| 00 00 00 00 20 20 20 36 | 34 34 20 00 20 20 20 20 |.... 6|44 . |
|00004c70| 20 30 20 00 20 20 20 20 | 32 35 20 00 20 20 20 20 | 0 . |25 . |
|00004c80| 20 20 37 36 34 36 33 20 | 20 35 33 34 32 37 33 32 | 76463 | 5342732|
|00004c90| 37 30 30 20 20 20 36 35 | 34 35 00 20 00 00 00 00 |700 65|45. ....|
|00004ca0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004cb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004cc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004cd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ce0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004cf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d00| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004d90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004da0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004db0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004dc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004dd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004de0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004df0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004e00| 2f 2a 0a 20 20 54 68 69 | 73 20 73 6f 66 74 77 61 |/*. Thi|s softwa|
|00004e10| 72 65 20 69 73 20 63 6f | 70 79 72 69 67 68 74 65 |re is co|pyrighte|
|00004e20| 64 20 62 79 20 74 68 65 | 20 55 6e 69 76 65 72 73 |d by the| Univers|
|00004e30| 69 74 79 20 6f 66 20 50 | 65 6e 6e 73 79 6c 76 61 |ity of P|ennsylva|
|00004e40| 6e 69 61 2e 0a 20 20 52 | 65 61 64 20 43 4f 50 59 |nia.. R|ead COPY|
|00004e50| 52 49 47 48 54 20 66 6f | 72 20 64 65 74 61 69 6c |RIGHT fo|r detail|
|00004e60| 73 2e 0a 0a 20 20 2a 2f | 0a 0a 2f 2a 0a 20 20 20 |s... */|../*. |
|00004e70| 20 41 73 73 75 6d 65 20 | 6d 6f 73 74 6c 79 20 74 | Assume |mostly t|
|00004e80| 68 65 20 73 61 6d 65 20 | 73 74 72 61 74 65 67 79 |he same |strategy|
|00004e90| 20 61 73 20 74 68 65 20 | 54 65 63 68 49 6e 66 6f | as the |TechInfo|
|00004ea0| 20 73 65 72 76 65 72 0a | 20 20 20 20 61 6e 64 20 | server.| and |
|00004eb0| 70 75 74 20 61 6c 6c 20 | 64 61 74 61 20 69 6e 74 |put all |data int|
|00004ec0| 6f 20 61 20 62 75 66 66 | 65 72 20 66 6f 72 20 74 |o a buff|er for t|
|00004ed0| 68 65 20 63 6f 6e 6e 65 | 63 74 69 6f 6e 2e 0a 0a |he conne|ction...|
|00004ee0| 0a 20 20 20 20 48 6f 77 | 65 76 65 72 2c 20 69 66 |. How|ever, if|
|00004ef0| 20 74 68 65 20 74 72 61 | 6e 73 61 63 74 69 6f 6e | the tra|nsaction|
|00004f00| 20 72 65 71 75 69 72 65 | 73 20 63 6f 6e 6e 65 63 | require|s connec|
|00004f10| 74 69 6e 67 20 74 6f 20 | 67 6f 70 68 65 72 2c 20 |ting to |gopher, |
|00004f20| 74 68 65 6e 0a 20 20 20 | 20 66 6f 72 6b 20 61 20 |then. | fork a |
|00004f30| 63 68 69 6c 64 2c 20 77 | 68 69 63 68 20 77 69 6c |child, w|hich wil|
|00004f40| 6c 20 65 78 65 63 20 61 | 20 6e 65 77 20 70 72 6f |l exec a| new pro|
|00004f50| 67 72 61 6d 20 77 69 74 | 68 20 74 68 65 20 72 69 |gram wit|h the ri|
|00004f60| 67 68 74 0a 20 20 20 20 | 61 72 67 76 5b 5d 2c 20 |ght. |argv[], |
|00004f70| 61 6e 64 20 70 61 72 65 | 6e 74 20 77 69 6c 6c 20 |and pare|nt will |
|00004f80| 63 72 65 61 74 65 20 63 | 5f 68 65 6c 70 65 72 20 |create c|_helper |
|00004f90| 66 6f 72 20 74 68 65 20 | 63 6f 6e 6e 65 63 74 69 |for the |connecti|
|00004fa0| 6f 6e 2e 0a 20 20 20 20 | 57 68 65 6e 20 74 68 65 |on.. |When the|
|00004fb0| 20 73 65 72 76 65 72 20 | 72 65 63 65 69 76 65 73 | server |receives|
|00004fc0| 20 74 68 65 20 73 69 67 | 6e 61 6c 20 74 68 61 74 | the sig|nal that|
|00004fd0| 0a 20 20 20 20 74 68 65 | 20 63 68 69 6c 64 20 69 |. the| child i|
|00004fe0| 73 20 64 6f 6e 65 2c 20 | 69 74 20 77 69 6c 6c 20 |s done, |it will |
|00004ff0| 72 65 61 64 20 74 68 65 | 20 63 68 69 6c 64 27 73 |read the| child's|
|00005000| 20 6f 75 74 70 75 74 20 | 66 69 6c 65 2c 0a 20 20 | output |file,. |
|00005010| 20 20 74 72 61 6e 73 6c | 61 74 65 20 69 74 20 61 | transl|ate it a|
|00005020| 6e 64 20 77 72 69 74 65 | 20 61 20 54 65 63 68 49 |nd write| a TechI|
|00005030| 6e 66 6f 20 66 6f 72 6d | 61 74 74 65 64 20 66 69 |nfo form|atted fi|
|00005040| 6c 65 20 61 6e 64 20 63 | 61 6c 6c 0a 20 20 20 20 |le and c|all. |
|00005050| 6e 69 6f 5f 73 65 6e 64 | 5f 66 69 6c 65 28 29 2e |nio_send|_file().|
|00005060| 20 20 54 68 65 6e 20 72 | 65 6d 6f 76 65 5f 68 65 | Then r|emove_he|
|00005070| 6c 70 65 72 20 66 6f 72 | 20 74 68 65 20 63 6f 6e |lper for| the con|
|00005080| 6e 65 63 74 69 6f 6e 2e | 0a 0a 20 20 20 20 49 66 |nection.|.. If|
|00005090| 20 61 20 66 69 6c 65 20 | 63 6f 6e 74 61 69 6e 69 | a file |containi|
|000050a0| 6e 67 20 74 68 65 20 67 | 6f 70 68 65 72 20 69 6e |ng the g|opher in|
|000050b0| 66 6f 72 6d 61 74 69 6f | 6e 20 69 73 20 61 6c 72 |formatio|n is alr|
|000050c0| 65 61 64 79 0a 20 20 20 | 20 63 61 63 68 65 64 20 |eady. | cached |
|000050d0| 61 6e 64 20 69 73 6e 27 | 74 20 74 6f 6f 20 6f 6c |and isn'|t too ol|
|000050e0| 64 2c 20 75 73 65 20 69 | 74 20 69 6e 73 74 65 61 |d, use i|t instea|
|000050f0| 64 20 6f 66 20 63 6f 6e | 6e 65 63 74 69 6e 67 20 |d of con|necting |
|00005100| 74 6f 20 67 6f 70 68 65 | 72 2e 0a 0a 20 20 20 20 |to gophe|r... |
|00005110| 54 68 69 73 20 69 73 20 | 62 61 73 69 63 61 6c 6c |This is |basicall|
|00005120| 79 20 61 20 63 6f 6d 70 | 6c 65 74 65 20 72 65 77 |y a comp|lete rew|
|00005130| 72 69 74 65 20 6f 66 20 | 4d 49 54 27 73 20 74 72 |rite of |MIT's tr|
|00005140| 61 6e 73 61 63 74 2e 63 | 20 63 6f 64 65 2e 0a 20 |ansact.c| code.. |
|00005150| 20 20 20 49 20 2a 72 65 | 61 6c 6c 79 2a 20 64 69 | I *re|ally* di|
|00005160| 73 6c 69 6b 65 64 20 74 | 68 65 20 65 78 74 65 6e |sliked t|he exten|
|00005170| 73 69 76 65 20 75 73 65 | 20 6f 66 20 76 61 72 69 |sive use| of vari|
|00005180| 61 62 6c 65 73 20 77 68 | 6f 73 65 20 73 63 6f 70 |ables wh|ose scop|
|00005190| 65 0a 20 20 20 20 77 61 | 73 20 74 68 65 20 65 6e |e. wa|s the en|
|000051a0| 74 69 72 65 20 6d 6f 64 | 75 6c 65 2e 20 20 49 20 |tire mod|ule. I |
|000051b0| 6c 69 6b 65 20 74 6f 20 | 70 61 73 73 20 70 61 72 |like to |pass par|
|000051c0| 61 6d 65 74 65 72 20 6c | 69 73 74 73 2c 20 65 76 |ameter l|ists, ev|
|000051d0| 65 6e 20 69 66 0a 20 20 | 20 20 74 68 65 79 20 67 |en if. | they g|
|000051e0| 65 74 20 63 75 6d 62 65 | 72 73 6f 6d 65 2e 20 20 |et cumbe|rsome. |
|000051f0| 4c 65 73 73 20 63 6f 6e | 66 75 73 69 6f 6e 20 69 |Less con|fusion i|
|00005200| 6e 20 74 68 65 20 6c 6f | 6e 67 20 72 75 6e 20 61 |n the lo|ng run a|
|00005210| 62 6f 75 74 0a 20 20 20 | 20 77 68 61 74 20 67 65 |bout. | what ge|
|00005220| 74 73 20 75 73 65 64 2c | 20 77 68 61 74 20 67 65 |ts used,| what ge|
|00005230| 74 73 20 63 68 61 6e 67 | 65 64 2e 0a 20 20 20 20 |ts chang|ed.. |
|00005240| 0a 20 20 20 20 2a 2f 0a | 0a 23 69 6e 63 6c 75 64 |. */.|.#includ|
|00005250| 65 20 3c 73 74 64 69 6f | 2e 68 3e 0a 23 69 6e 63 |e <stdio|.h>.#inc|
|00005260| 6c 75 64 65 20 3c 75 6e | 69 73 74 64 2e 68 3e 0a |lude <un|istd.h>.|
|00005270| 23 69 6e 63 6c 75 64 65 | 20 3c 73 79 73 2f 66 69 |#include| <sys/fi|
|00005280| 6c 65 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |le.h>.#i|nclude <|
|00005290| 73 79 73 2f 74 79 70 65 | 73 2e 68 3e 0a 23 69 6e |sys/type|s.h>.#in|
|000052a0| 63 6c 75 64 65 20 3c 65 | 72 72 6e 6f 2e 68 3e 0a |clude <e|rrno.h>.|
|000052b0| 23 69 6e 63 6c 75 64 65 | 20 3c 73 79 73 2f 74 69 |#include| <sys/ti|
|000052c0| 6d 65 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |me.h>.#i|nclude <|
|000052d0| 73 79 73 2f 77 61 69 74 | 2e 68 3e 0a 23 69 6e 63 |sys/wait|.h>.#inc|
|000052e0| 6c 75 64 65 20 3c 73 79 | 73 2f 73 74 61 74 2e 68 |lude <sy|s/stat.h|
|000052f0| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 79 73 2f |>.#inclu|de <sys/|
|00005300| 72 65 73 6f 75 72 63 65 | 2e 68 3e 0a 23 69 6e 63 |resource|.h>.#inc|
|00005310| 6c 75 64 65 20 3c 73 74 | 72 69 6e 67 73 2e 68 3e |lude <st|rings.h>|
|00005320| 0a 23 69 6e 63 6c 75 64 | 65 20 3c 73 79 73 2f 69 |.#includ|e <sys/i|
|00005330| 6f 63 74 6c 2e 68 3e 20 | 2f 2a 2a 2f 0a 23 69 6e |octl.h> |/**/.#in|
|00005340| 63 6c 75 64 65 20 3c 73 | 69 67 6e 61 6c 2e 68 3e |clude <s|ignal.h>|
|00005350| 0a 0a 23 69 6e 63 6c 75 | 64 65 20 22 67 6f 70 68 |..#inclu|de "goph|
|00005360| 65 72 6e 6f 64 65 73 2e | 68 22 20 20 2f 2a 20 6e |ernodes.|h" /* n|
|00005370| 65 77 20 66 6f 72 20 74 | 65 63 68 69 6e 70 68 65 |ew for t|echinphe|
|00005380| 72 20 67 61 74 65 77 61 | 79 20 2a 2f 0a 23 69 6e |r gatewa|y */.#in|
|00005390| 63 6c 75 64 65 20 22 6e | 65 74 77 6f 72 6b 2e 68 |clude "n|etwork.h|
|000053a0| 22 0a 23 69 6e 63 6c 75 | 64 65 20 22 70 64 62 2e |".#inclu|de "pdb.|
|000053b0| 68 22 0a 23 69 6e 63 6c | 75 64 65 20 22 6d 65 73 |h".#incl|ude "mes|
|000053c0| 73 61 67 65 73 2e 68 22 | 0a 23 69 6e 63 6c 75 64 |sages.h"|.#includ|
|000053d0| 65 20 22 6e 6f 64 65 2e | 68 22 0a 0a 0a 76 6f 69 |e "node.|h"...voi|
|000053e0| 64 20 61 64 6d 69 6e 28 | 69 6e 74 20 6e 75 6d 66 |d admin(|int numf|
|000053f0| 2c 20 63 68 61 72 20 2a | 2a 66 69 65 6c 64 73 2c |, char *|*fields,|
|00005400| 20 69 6e 74 20 73 6f 63 | 6b 29 3b 0a 76 6f 69 64 | int soc|k);.void|
|00005410| 20 63 68 61 6e 67 65 5f | 66 6f 72 6d 61 74 28 69 | change_|format(i|
|00005420| 6e 74 20 2a 66 6d 74 2c | 20 69 6e 74 20 73 6f 63 |nt *fmt,| int soc|
|00005430| 6b 2c 20 69 6e 74 20 6e | 75 6d 66 2c 20 63 68 61 |k, int n|umf, cha|
|00005440| 72 20 2a 2a 66 69 65 6c | 64 73 29 3b 0a 76 6f 69 |r **fiel|ds);.voi|
|00005450| 64 20 66 69 6e 64 28 43 | 4f 4e 4e 20 2a 63 6f 6e |d find(C|ONN *con|
|00005460| 6e 2c 20 63 68 61 72 20 | 63 68 2c 20 69 6e 74 20 |n, char |ch, int |
|00005470| 6e 75 6d 66 2c 20 63 68 | 61 72 20 2a 2a 66 69 65 |numf, ch|ar **fie|
|00005480| 6c 64 73 20 29 3b 0a 63 | 68 61 72 20 2a 66 69 6e |lds );.c|har *fin|
|00005490| 64 5f 61 62 62 72 65 76 | 28 63 68 61 72 20 63 68 |d_abbrev|(char ch|
|000054a0| 29 3b 0a 76 6f 69 64 20 | 66 69 6e 64 5f 76 65 72 |);.void |find_ver|
|000054b0| 28 43 4f 4e 4e 20 2a 63 | 6f 6e 6e 2c 20 69 6e 74 |(CONN *c|onn, int|
|000054c0| 20 6e 75 6d 66 2c 20 63 | 68 61 72 20 2a 2a 66 69 | numf, c|har **fi|
|000054d0| 65 6c 64 73 29 3b 0a 69 | 6e 74 20 68 64 6c 5f 74 |elds);.i|nt hdl_t|
|000054e0| 72 61 6e 73 61 63 74 28 | 43 4f 4e 4e 20 2a 63 6f |ransact(|CONN *co|
|000054f0| 6e 6e 29 3b 0a 76 6f 69 | 64 20 6c 6f 67 5f 74 72 |nn);.voi|d log_tr|
|00005500| 61 6e 73 28 63 68 61 72 | 20 2a 6c 69 6e 65 29 3b |ans(char| *line);|
|00005510| 0a 63 68 61 72 20 2a 6e | 6f 64 65 69 6e 66 6f 73 |.char *n|odeinfos|
|00005520| 74 72 20 28 6c 6f 6e 67 | 20 6e 6f 64 65 69 64 2c |tr (long| nodeid,|
|00005530| 20 73 74 72 75 63 74 20 | 73 31 20 2a 6e 64 2c 20 | struct |s1 *nd, |
|00005540| 69 6e 74 20 66 6c 67 73 | 66 6d 74 29 3b 0a 76 6f |int flgs|fmt);.vo|
|00005550| 69 64 20 70 72 6f 63 5f | 74 72 61 6e 73 28 69 6e |id proc_|trans(in|
|00005560| 74 20 6e 75 6d 66 2c 20 | 63 68 61 72 20 63 68 2c |t numf, |char ch,|
|00005570| 20 63 68 61 72 20 2a 2a | 66 69 65 6c 64 73 2c 20 | char **|fields, |
|00005580| 43 4f 4e 4e 20 2a 63 6f | 6e 6e 29 3b 0a 76 6f 69 |CONN *co|nn);.voi|
|00005590| 64 20 73 65 6e 64 5f 63 | 6f 6e 6e 65 63 74 69 6f |d send_c|onnectio|
|000055a0| 6e 73 28 69 6e 74 20 73 | 6f 63 6b 29 3b 0a 76 6f |ns(int s|ock);.vo|
|000055b0| 69 64 20 73 65 6e 64 5f | 65 6d 70 74 79 5f 64 6f |id send_|empty_do|
|000055c0| 63 75 6d 65 6e 74 28 69 | 6e 74 20 73 6f 63 6b 29 |cument(i|nt sock)|
|000055d0| 3b 0a 76 6f 69 64 20 73 | 65 6e 64 5f 65 6d 70 74 |;.void s|end_empt|
|000055e0| 79 5f 6d 65 6e 75 28 69 | 6e 74 20 73 6f 63 6b 29 |y_menu(i|nt sock)|
|000055f0| 3b 0a 76 6f 69 64 20 73 | 65 6e 64 5f 66 69 6c 65 |;.void s|end_file|
|00005600| 28 43 4f 4e 4e 20 2a 63 | 6f 6e 6e 2c 20 63 68 61 |(CONN *c|onn, cha|
|00005610| 72 20 74 74 79 70 65 2c | 20 69 6e 74 20 6e 75 6d |r ttype,| int num|
|00005620| 66 2c 20 63 68 61 72 20 | 2a 2a 66 69 65 6c 64 73 |f, char |**fields|
|00005630| 29 3b 0a 76 6f 69 64 20 | 73 65 6e 64 5f 67 6f 70 |);.void |send_gop|
|00005640| 68 65 72 5f 69 6e 66 6f | 28 73 74 72 75 63 74 20 |her_info|(struct |
|00005650| 73 31 20 2a 6e 64 2c 20 | 69 6e 74 20 6e 75 6d 66 |s1 *nd, |int numf|
|00005660| 2c 20 63 68 61 72 20 2a | 2a 66 69 65 6c 64 73 2c |, char *|*fields,|
|00005670| 20 43 4f 4e 4e 20 2a 63 | 75 72 72 63 6f 6e 29 3b | CONN *c|urrcon);|
|00005680| 0a 76 6f 69 64 20 73 65 | 6e 64 5f 68 65 6c 70 28 |.void se|nd_help(|
|00005690| 69 6e 74 20 73 6f 63 6b | 29 3b 0a 76 6f 69 64 20 |int sock|);.void |
|000056a0| 73 65 6e 64 5f 6e 6f 64 | 65 28 69 6e 74 20 66 6c |send_nod|e(int fl|
|000056b0| 67 73 66 6d 74 2c 20 69 | 6e 74 20 73 6f 63 6b 2c |gsfmt, i|nt sock,|
|000056c0| 20 69 6e 74 20 6e 75 6d | 66 2c 20 63 68 61 72 20 | int num|f, char |
|000056d0| 2a 2a 74 72 61 6e 73 66 | 69 65 6c 64 73 29 3b 0a |**transf|ields);.|
|000056e0| 69 6e 74 20 73 65 6e 64 | 5f 72 65 73 65 72 76 65 |int send|_reserve|
|000056f0| 64 5f 6e 6f 64 65 20 28 | 63 68 61 72 20 74 72 61 |d_node (|char tra|
|00005700| 6e 73 5f 74 79 70 65 2c | 20 69 6e 74 20 6e 75 6d |ns_type,| int num|
|00005710| 66 2c 20 63 68 61 72 20 | 2a 2a 66 69 65 6c 64 73 |f, char |**fields|
|00005720| 2c 20 6c 6f 6e 67 20 6e | 6f 64 65 69 64 2c 20 69 |, long n|odeid, i|
|00005730| 6e 74 20 66 6c 67 73 66 | 6d 74 2c 20 69 6e 74 20 |nt flgsf|mt, int |
|00005740| 63 75 72 5f 73 6f 63 6b | 29 3b 0a 76 6f 69 64 20 |cur_sock|);.void |
|00005750| 73 65 6e 64 5f 73 72 63 | 5f 69 6e 66 6f 28 69 6e |send_src|_info(in|
|00005760| 74 20 73 6f 63 6b 29 3b | 0a 76 6f 69 64 20 73 65 |t sock);|.void se|
|00005770| 6e 64 5f 73 65 72 76 65 | 72 73 5f 6c 69 73 74 28 |nd_serve|rs_list(|
|00005780| 69 6e 74 20 73 6f 63 6b | 29 3b 0a 69 6e 74 20 74 |int sock|);.int t|
|00005790| 65 73 74 5f 61 64 6d 69 | 6e 28 63 68 61 72 20 2a |est_admi|n(char *|
|000057a0| 70 61 73 73 77 64 29 3b | 0a 76 6f 69 64 20 74 72 |passwd);|.void tr|
|000057b0| 61 76 65 72 73 65 28 43 | 4f 4e 4e 20 2a 63 6f 6e |averse(C|ONN *con|
|000057c0| 6e 2c 20 63 68 61 72 20 | 63 68 2c 20 69 6e 74 20 |n, char |ch, int |
|000057d0| 6e 75 6d 66 2c 20 63 68 | 61 72 20 2a 2a 66 69 65 |numf, ch|ar **fie|
|000057e0| 6c 64 73 29 3b 0a 0a 0a | 65 78 74 65 72 6e 20 63 |lds);...|extern c|
|000057f0| 68 61 72 20 20 20 20 20 | 2a 6d 73 67 6c 69 73 74 |har |*msglist|
|00005800| 5b 5d 3b 20 2f 2a 20 74 | 68 65 20 6c 69 73 74 20 |[]; /* t|he list |
|00005810| 6f 66 20 65 72 72 6f 72 | 20 6d 65 73 73 61 67 65 |of error| message|
|00005820| 73 20 2a 2f 0a 65 78 74 | 65 72 6e 20 69 6e 74 20 |s */.ext|ern int |
|00005830| 20 20 20 20 20 64 65 62 | 75 67 3b 0a 65 78 74 65 | deb|ug;.exte|
|00005840| 72 6e 20 73 68 6f 72 74 | 20 20 20 20 74 6f 64 61 |rn short| toda|
|00005850| 79 73 64 61 74 65 3b 0a | 65 78 74 65 72 6e 20 69 |ysdate;.|extern i|
|00005860| 6e 74 20 20 20 20 20 20 | 74 61 62 6c 65 73 5f 63 |nt |tables_c|
|00005870| 68 61 6e 67 65 64 3b 0a | 65 78 74 65 72 6e 20 69 |hanged;.|extern i|
|00005880| 6e 74 20 20 20 20 20 20 | 6c 61 73 74 75 73 65 64 |nt |lastused|
|00005890| 5f 63 68 61 6e 67 65 64 | 3b 0a 65 78 74 65 72 6e |_changed|;.extern|
|000058a0| 20 76 6f 69 64 20 20 20 | 20 20 70 61 72 73 65 66 | void | parsef|
|000058b0| 69 65 6c 64 73 28 29 3b | 0a 65 78 74 65 72 6e 20 |ields();|.extern |
|000058c0| 73 74 72 75 63 74 20 73 | 31 20 2a 67 65 74 6e 6f |struct s|1 *getno|
|000058d0| 64 65 5f 62 79 6e 6f 64 | 65 69 64 28 6c 6f 6e 67 |de_bynod|eid(long|
|000058e0| 20 6e 69 64 29 3b 0a 65 | 78 74 65 72 6e 20 76 6f | nid);.e|xtern vo|
|000058f0| 69 64 20 20 20 20 20 63 | 61 74 63 68 5f 63 68 69 |id c|atch_chi|
|00005900| 6c 64 28 29 3b 0a 65 78 | 74 65 72 6e 20 76 6f 69 |ld();.ex|tern voi|
|00005910| 64 20 20 20 20 20 6e 69 | 6f 5f 73 65 6e 64 5f 66 |d ni|o_send_f|
|00005920| 69 6c 65 28 69 6e 74 20 | 73 2c 20 63 68 61 72 20 |ile(int |s, char |
|00005930| 2a 66 6e 2c 20 6c 6f 6e | 67 20 73 74 70 74 2c 20 |*fn, lon|g stpt, |
|00005940| 6c 6f 6e 67 20 72 65 71 | 2c 20 69 6e 74 20 69 73 |long req|, int is|
|00005950| 6e 6c 69 73 74 29 3b 0a | 65 78 74 65 72 6e 20 76 |nlist);.|extern v|
|00005960| 6f 69 64 20 20 20 20 20 | 73 65 6e 64 5f 6d 73 67 |oid |send_msg|
|00005970| 20 28 63 68 61 72 20 2a | 73 74 72 69 6e 67 2c 20 | (char *|string, |
|00005980| 69 6e 74 20 73 6f 63 6b | 29 3b 0a 65 78 74 65 72 |int sock|);.exter|
|00005990| 6e 20 69 6e 74 20 20 20 | 20 20 20 73 65 6e 64 62 |n int | sendb|
|000059a0| 75 66 20 20 28 63 68 61 | 72 20 2a 63 70 2c 20 69 |uf (cha|r *cp, i|
|000059b0| 6e 74 20 73 7a 2c 20 69 | 6e 74 20 73 6f 63 6b 29 |nt sz, i|nt sock)|
|000059c0| 3b 0a 0a 69 6e 74 20 20 | 20 20 20 20 20 20 20 20 |;..int | |
|000059d0| 20 20 20 6d 61 78 5f 73 | 74 61 6c 65 5f 74 69 6d | max_s|tale_tim|
|000059e0| 65 3b 20 20 2f 2a 20 6e | 6f 74 20 75 73 65 64 2c |e; /* n|ot used,|
|000059f0| 20 62 75 74 20 69 74 27 | 73 20 69 6e 20 73 65 72 | but it'|s in ser|
|00005a00| 76 65 72 2e 63 20 2a 2f | 0a 73 74 61 74 69 63 20 |ver.c */|.static |
|00005a10| 63 68 61 72 20 20 20 20 | 20 2a 63 75 72 72 5f 75 |char | *curr_u|
|00005a20| 69 64 3b 20 20 2f 2a 20 | 73 68 6f 75 6c 64 20 67 |id; /* |should g|
|00005a30| 65 74 20 72 69 64 20 6f | 66 20 74 68 69 73 20 6f |et rid o|f this o|
|00005a40| 6e 65 20 74 6f 6f 20 2a | 2f 0a 73 74 61 74 69 63 |ne too *|/.static|
|00005a50| 20 63 68 61 72 20 20 20 | 20 20 69 6e 5f 62 75 66 | char | in_buf|
|00005a60| 66 5b 42 55 46 53 49 5a | 5d 3b 20 20 2f 2a 20 68 |f[BUFSIZ|]; /* h|
|00005a70| 6f 6c 64 73 20 74 72 61 | 6e 73 61 63 74 69 6f 6e |olds tra|nsaction|
|00005a80| 20 66 72 6f 6d 20 63 6c | 69 65 6e 74 20 2a 2f 0a | from cl|ient */.|
|00005a90| 73 74 61 74 69 63 20 63 | 68 61 72 20 20 20 20 20 |static c|har |
|00005aa0| 6e 6f 64 65 69 6e 66 6f | 62 75 66 5b 42 55 46 53 |nodeinfo|buf[BUFS|
|00005ab0| 49 5a 5d 3b 0a 0a 0a 0a | 73 74 72 75 63 74 20 67 |IZ];....|struct g|
|00005ac0| 6f 70 68 65 72 61 62 62 | 72 65 76 20 67 6f 70 68 |opherabb|rev goph|
|00005ad0| 65 72 5f 61 62 62 72 65 | 76 5b 5d 20 3d 0a 7b 20 |er_abbre|v[] =.{ |
|00005ae0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00005af0| 20 2f 2a 20 6c 65 61 76 | 69 6e 67 20 6f 75 74 20 | /* leav|ing out |
|00005b00| 45 52 52 4f 52 20 61 6e | 64 20 44 55 50 53 52 56 |ERROR an|d DUPSRV|
|00005b10| 20 2a 2f 0a 20 20 7b 47 | 4f 50 48 54 59 50 5f 54 | */. {G|OPHTYP_T|
|00005b20| 45 58 54 2c 20 20 20 20 | 20 20 20 20 22 2e 22 7d |EXT, | "."}|
|00005b30| 2c 0a 20 20 7b 47 4f 50 | 48 54 59 50 5f 4d 45 4e |,. {GOP|HTYP_MEN|
|00005b40| 55 2c 20 20 20 20 20 20 | 20 20 22 2f 22 7d 2c 0a |U, | "/"},.|
|00005b50| 20 20 7b 47 4f 50 48 54 | 59 50 5f 43 53 4f 2c 20 | {GOPHT|YP_CSO, |
|00005b60| 20 20 20 20 20 20 20 20 | 22 20 3c 43 53 4f 3e 22 | |" <CSO>"|
|00005b70| 7d 2c 0a 20 20 7b 47 4f | 50 48 54 59 50 5f 4d 41 |},. {GO|PHTYP_MA|
|00005b80| 43 48 51 58 2c 20 20 20 | 20 20 20 22 20 3c 48 51 |CHQX, | " <HQ|
|00005b90| 58 3e 22 7d 2c 0a 20 20 | 7b 47 4f 50 48 54 59 50 |X>"},. |{GOPHTYP|
|00005ba0| 5f 44 4f 53 42 49 4e 2c | 20 20 20 20 20 20 22 20 |_DOSBIN,| " |
|00005bb0| 3c 50 43 20 42 69 6e 3e | 22 7d 2c 0a 20 20 7b 47 |<PC Bin>|"},. {G|
|00005bc0| 4f 50 48 54 59 50 5f 55 | 55 45 4e 43 2c 20 20 20 |OPHTYP_U|UENC, |
|00005bd0| 20 20 20 20 22 20 3c 55 | 55 45 4e 43 3e 22 7d 2c | " <U|UENC>"},|
|00005be0| 0a 20 20 7b 47 4f 50 48 | 54 59 50 5f 53 45 41 52 |. {GOPH|TYP_SEAR|
|00005bf0| 43 48 2c 20 20 20 20 20 | 20 22 20 3c 3f 3e 22 7d |CH, | " <?>"}|
|00005c00| 2c 0a 20 20 7b 47 4f 50 | 48 54 59 50 5f 54 45 4c |,. {GOP|HTYP_TEL|
|00005c10| 4e 45 54 2c 20 20 20 20 | 20 20 22 20 3c 54 45 4c |NET, | " <TEL|
|00005c20| 3e 22 7d 2c 0a 20 20 7b | 47 4f 50 48 54 59 50 5f |>"},. {|GOPHTYP_|
|00005c30| 42 49 4e 41 52 59 2c 20 | 20 20 20 20 20 22 20 3c |BINARY, | " <|
|00005c40| 42 69 6e 3e 22 7d 2c 0a | 20 20 7b 47 4f 50 48 54 |Bin>"},.| {GOPHT|
|00005c50| 59 50 5f 47 49 46 2c 20 | 20 20 20 20 20 20 20 20 |YP_GIF, | |
|00005c60| 22 20 3c 50 69 63 74 75 | 72 65 3e 22 7d 2c 0a 20 |" <Pictu|re>"},. |
|00005c70| 20 7b 47 4f 50 48 54 59 | 50 5f 49 4d 41 47 45 2c | {GOPHTY|P_IMAGE,|
|00005c80| 20 20 20 20 20 20 20 22 | 20 3c 50 69 63 74 75 72 | "| <Pictur|
|00005c90| 65 3e 22 7d 2c 0a 20 20 | 7b 47 4f 50 48 54 59 50 |e>"},. |{GOPHTYP|
|00005ca0| 5f 54 4e 33 32 37 30 2c | 20 20 20 20 20 20 22 20 |_TN3270,| " |
|00005cb0| 3c 33 32 37 30 3e 22 7d | 2c 0a 20 20 7b 47 4f 50 |<3270>"}|,. {GOP|
|00005cc0| 48 54 59 50 5f 53 4f 55 | 4e 44 2c 20 20 20 20 20 |HTYP_SOU|ND, |
|00005cd0| 20 20 22 20 3c 29 22 7d | 2c 0a 20 20 7b 47 4f 50 | " <)"}|,. {GOP|
|00005ce0| 48 54 59 50 5f 45 56 45 | 4e 54 2c 20 20 20 20 20 |HTYP_EVE|NT, |
|00005cf0| 20 20 22 20 3c 45 76 65 | 6e 74 3e 22 7d 2c 0a 20 | " <Eve|nt>"},. |
|00005d00| 20 7b 47 4f 50 48 54 59 | 50 5f 43 41 4c 45 4e 44 | {GOPHTY|P_CALEND|
|00005d10| 41 52 2c 20 20 20 20 22 | 20 3c 43 61 6c 3e 22 7d |AR, "| <Cal>"}|
|00005d20| 2c 0a 20 20 7b 47 4f 50 | 48 54 59 50 5f 4d 49 4d |,. {GOP|HTYP_MIM|
|00005d30| 45 2c 20 20 20 20 20 20 | 20 20 22 20 3c 4d 49 4d |E, | " <MIM|
|00005d40| 45 3e 22 7d 2c 0a 20 20 | 7b 47 4f 50 48 54 59 50 |E>"},. |{GOPHTYP|
|00005d50| 5f 48 54 4d 4c 2c 20 20 | 20 20 20 20 20 20 22 20 |_HTML, | " |
|00005d60| 3c 48 54 4d 4c 3e 22 7d | 0a 7d 3b 0a 23 64 65 66 |<HTML>"}|.};.#def|
|00005d70| 69 6e 65 20 4e 55 4d 5f | 47 4f 50 48 45 52 5f 41 |ine NUM_|GOPHER_A|
|00005d80| 42 42 52 45 56 20 31 37 | 0a 23 64 65 66 69 6e 65 |BBREV 17|.#define|
|00005d90| 20 67 6f 70 68 65 72 5f | 61 62 62 72 65 76 5f 75 | gopher_|abbrev_u|
|00005da0| 6e 6b 20 20 22 20 3c 55 | 6e 6b 6e 6f 77 6e 3e 22 |nk " <U|nknown>"|
|00005db0| 0a 0a 0a 69 6e 74 20 68 | 64 6c 5f 74 72 61 6e 73 |...int h|dl_trans|
|00005dc0| 61 63 74 28 43 4f 4e 4e | 20 2a 63 6f 6e 6e 29 0a |act(CONN| *conn).|
|00005dd0| 7b 0a 09 63 68 61 72 20 | 20 20 20 20 20 20 20 20 |{..char | |
|00005de0| 20 20 20 6c 6f 67 5f 6c | 69 6e 65 5b 42 55 46 53 | log_l|ine[BUFS|
|00005df0| 49 5a 5d 3b 0a 09 69 6e | 74 20 20 20 20 20 20 20 |IZ];..in|t |
|00005e00| 20 20 20 20 20 20 6c 65 | 6e 67 74 68 3b 0a 09 69 | le|ngth;..i|
|00005e10| 6e 74 20 20 20 20 20 20 | 20 20 20 20 20 20 20 66 |nt | f|
|00005e20| 3b 0a 09 69 6e 74 20 20 | 20 20 20 20 20 20 20 20 |;..int | |
|00005e30| 20 20 20 63 75 72 5f 73 | 6f 63 6b 3b 0a 09 63 68 | cur_s|ock;..ch|
|00005e40| 61 72 20 20 20 20 20 20 | 20 20 20 20 20 20 2a 74 |ar | *t|
|00005e50| 72 61 6e 73 66 69 65 6c | 64 73 5b 4d 41 58 5f 54 |ransfiel|ds[MAX_T|
|00005e60| 52 41 4e 53 5f 46 49 45 | 4c 44 53 5d 3b 0a 09 69 |RANS_FIE|LDS];..i|
|00005e70| 6e 74 20 20 20 20 20 20 | 20 20 20 20 20 20 20 6e |nt | n|
|00005e80| 75 6d 5f 74 72 61 6e 73 | 66 69 65 6c 64 73 3b 0a |um_trans|fields;.|
|00005e90| 09 63 68 61 72 20 20 20 | 20 20 20 20 20 20 20 20 |.char | |
|00005ea0| 20 74 72 61 6e 73 5f 74 | 79 70 65 3b 0a 0a 09 63 | trans_t|ype;...c|
|00005eb0| 75 72 72 5f 75 69 64 20 | 3d 20 63 6f 6e 6e 2d 3e |urr_uid |= conn->|
|00005ec0| 63 5f 75 69 64 3b 0a 09 | 63 6f 6e 6e 2d 3e 63 5f |c_uid;..|conn->c_|
|00005ed0| 74 72 61 6e 73 5f 63 6e | 74 2b 2b 3b 0a 09 63 75 |trans_cn|t++;..cu|
|00005ee0| 72 5f 73 6f 63 6b 20 3d | 20 63 6f 6e 6e 2d 3e 63 |r_sock =| conn->c|
|00005ef0| 5f 73 6f 63 6b 65 74 3b | 0a 0a 09 62 7a 65 72 6f |_socket;|...bzero|
|00005f00| 28 69 6e 5f 62 75 66 66 | 2c 20 42 55 46 53 49 5a |(in_buff|, BUFSIZ|
|00005f10| 29 3b 0a 09 6c 65 6e 67 | 74 68 20 3d 20 72 65 61 |);..leng|th = rea|
|00005f20| 64 28 63 75 72 5f 73 6f | 63 6b 2c 20 69 6e 5f 62 |d(cur_so|ck, in_b|
|00005f30| 75 66 66 2c 20 42 55 46 | 53 49 5a 29 3b 0a 09 69 |uff, BUF|SIZ);..i|
|00005f40| 66 20 28 6c 65 6e 67 74 | 68 20 3c 3d 20 30 29 20 |f (lengt|h <= 0) |
|00005f50| 7b 0a 09 20 20 69 66 20 | 28 6c 65 6e 67 74 68 29 |{.. if |(length)|
|00005f60| 0a 09 20 20 20 20 70 65 | 72 72 6f 72 28 22 73 6f |.. pe|rror("so|
|00005f70| 63 6b 65 74 20 72 65 61 | 64 22 29 3b 0a 09 20 20 |cket rea|d");.. |
|00005f80| 2f 2a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |/* | |
|00005f90| 20 20 69 66 20 28 65 72 | 72 6e 6f 20 3d 3d 20 45 | if (er|rno == E|
|00005fa0| 57 4f 55 4c 44 42 4c 4f | 43 4b 29 0a 09 09 09 20 |WOULDBLO|CK).... |
|00005fb0| 20 20 20 72 65 74 75 72 | 6e 20 30 3b 0a 09 09 09 | retur|n 0;....|
|00005fc0| 20 20 20 20 65 6c 73 65 | 20 0a 09 20 20 20 54 68 | else| .. Th|
|00005fd0| 69 73 20 63 61 75 73 65 | 64 20 6c 6f 6f 70 69 6e |is cause|d loopin|
|00005fe0| 67 20 65 72 72 6f 72 20 | 2d 53 54 20 2a 2f 0a 09 |g error |-ST */..|
|00005ff0| 20 20 72 65 74 75 72 6e | 20 31 3b 0a 09 7d 0a 09 | return| 1;..}..|
|00006000| 69 66 20 28 69 6e 5f 62 | 75 66 66 5b 6c 65 6e 67 |if (in_b|uff[leng|
|00006010| 74 68 20 2d 20 31 5d 20 | 3d 3d 20 4c 46 29 0a 09 |th - 1] |== LF)..|
|00006020| 09 6c 65 6e 67 74 68 2d | 2d 3b 0a 09 69 66 20 28 |.length-|-;..if (|
|00006030| 69 6e 5f 62 75 66 66 5b | 6c 65 6e 67 74 68 20 2d |in_buff[|length -|
|00006040| 20 31 5d 20 3d 3d 20 43 | 52 29 0a 09 09 6c 65 6e | 1] == C|R)...len|
|00006050| 67 74 68 2d 2d 3b 0a 09 | 69 6e 5f 62 75 66 66 5b |gth--;..|in_buff[|
|00006060| 6c 65 6e 67 74 68 5d 20 | 3d 20 27 5c 30 27 3b 0a |length] |= '\0';.|
|00006070| 09 0a 09 74 72 61 6e 73 | 5f 74 79 70 65 20 3d 20 |...trans|_type = |
|00006080| 2a 69 6e 5f 62 75 66 66 | 3b 0a 09 70 61 72 73 65 |*in_buff|;..parse|
|00006090| 66 69 65 6c 64 73 28 69 | 6e 5f 62 75 66 66 2c 20 |fields(i|n_buff, |
|000060a0| 74 72 61 6e 73 66 69 65 | 6c 64 73 2c 20 26 6e 75 |transfie|lds, &nu|
|000060b0| 6d 5f 74 72 61 6e 73 66 | 69 65 6c 64 73 2c 20 44 |m_transf|ields, D|
|000060c0| 4c 4d 2c 20 4d 41 58 5f | 54 52 41 4e 53 5f 46 49 |LM, MAX_|TRANS_FI|
|000060d0| 45 4c 44 53 2d 31 29 3b | 0a 09 0a 09 69 66 20 28 |ELDS-1);|....if (|
|000060e0| 6c 65 6e 67 74 68 20 3d | 3d 20 30 20 7c 7c 20 74 |length =|= 0 || t|
|000060f0| 72 61 6e 73 5f 74 79 70 | 65 20 3d 3d 20 54 5f 51 |rans_typ|e == T_Q|
|00006100| 55 49 54 29 0a 09 20 20 | 72 65 74 75 72 6e 20 31 |UIT).. |return 1|
|00006110| 3b 09 2f 2a 20 71 75 69 | 74 20 61 6e 64 20 63 6c |;./* qui|t and cl|
|00006120| 6f 73 65 20 63 6f 6e 6e | 65 63 74 69 6f 6e 20 2a |ose conn|ection *|
|00006130| 2f 0a 09 0a 09 69 66 20 | 28 74 72 61 6e 73 5f 74 |/....if |(trans_t|
|00006140| 79 70 65 20 3d 3d 20 54 | 5f 41 44 4d 49 4e 29 0a |ype == T|_ADMIN).|
|00006150| 09 20 20 73 70 72 69 6e | 74 66 28 6c 6f 67 5f 6c |. sprin|tf(log_l|
|00006160| 69 6e 65 2c 20 22 25 73 | 3a 25 64 3a 25 63 22 2c |ine, "%s|:%d:%c",|
|00006170| 20 63 75 72 72 5f 75 69 | 64 2c 20 63 75 72 5f 73 | curr_ui|d, cur_s|
|00006180| 6f 63 6b 2c 20 74 72 61 | 6e 73 5f 74 79 70 65 29 |ock, tra|ns_type)|
|00006190| 3b 0a 09 65 6c 73 65 20 | 69 66 20 28 74 72 61 6e |;..else |if (tran|
|000061a0| 73 5f 74 79 70 65 20 3d | 3d 20 54 5f 54 52 59 50 |s_type =|= T_TRYP|
|000061b0| 52 4f 56 49 44 45 52 29 | 0a 09 20 20 73 70 72 69 |ROVIDER)|.. spri|
|000061c0| 6e 74 66 28 6c 6f 67 5f | 6c 69 6e 65 2c 20 22 25 |ntf(log_|line, "%|
|000061d0| 73 3a 25 64 3a 25 63 3a | 25 73 22 2c 20 63 75 72 |s:%d:%c:|%s", cur|
|000061e0| 72 5f 75 69 64 2c 63 75 | 72 5f 73 6f 63 6b 2c 74 |r_uid,cu|r_sock,t|
|000061f0| 72 61 6e 73 5f 74 79 70 | 65 2c 0a 09 09 20 20 6e |rans_typ|e,... n|
|00006200| 75 6d 5f 74 72 61 6e 73 | 66 69 65 6c 64 73 20 3c |um_trans|fields <|
|00006210| 20 32 20 3f 20 22 22 20 | 3a 20 74 72 61 6e 73 66 | 2 ? "" |: transf|
|00006220| 69 65 6c 64 73 5b 31 5d | 29 3b 0a 09 65 6c 73 65 |ields[1]|);..else|
|00006230| 20 7b 0a 09 20 20 73 70 | 72 69 6e 74 66 20 28 6c | {.. sp|rintf (l|
|00006240| 6f 67 5f 6c 69 6e 65 2c | 20 22 25 73 3a 25 64 22 |og_line,| "%s:%d"|
|00006250| 2c 20 63 75 72 72 5f 75 | 69 64 2c 20 63 75 72 5f |, curr_u|id, cur_|
|00006260| 73 6f 63 6b 29 3b 0a 09 | 20 20 66 6f 72 20 28 66 |sock);..| for (f|
|00006270| 3d 30 3b 20 66 20 3c 20 | 6e 75 6d 5f 74 72 61 6e |=0; f < |num_tran|
|00006280| 73 66 69 65 6c 64 73 3b | 20 66 2b 2b 29 20 7b 0a |sfields;| f++) {.|
|00006290| 09 20 20 20 20 73 74 72 | 63 61 74 20 28 6c 6f 67 |. str|cat (log|
|000062a0| 5f 6c 69 6e 65 2c 20 22 | 3a 22 29 3b 0a 09 20 20 |_line, "|:");.. |
|000062b0| 20 20 73 74 72 63 61 74 | 20 28 6c 6f 67 5f 6c 69 | strcat| (log_li|
|000062c0| 6e 65 2c 20 74 72 61 6e | 73 66 69 65 6c 64 73 5b |ne, tran|sfields[|
|000062d0| 66 5d 29 3b 0a 09 20 20 | 7d 0a 09 7d 0a 09 6c 6f |f]);.. |}..}..lo|
|000062e0| 67 5f 74 72 61 6e 73 28 | 6c 6f 67 5f 6c 69 6e 65 |g_trans(|log_line|
|000062f0| 29 3b 09 2f 2a 20 6c 6f | 67 20 74 68 65 20 74 72 |);./* lo|g the tr|
|00006300| 61 6e 73 61 63 74 69 6f | 6e 20 2a 2f 0a 09 28 76 |ansactio|n */..(v|
|00006310| 6f 69 64 29 20 70 72 6f | 63 5f 74 72 61 6e 73 20 |oid) pro|c_trans |
|00006320| 28 6e 75 6d 5f 74 72 61 | 6e 73 66 69 65 6c 64 73 |(num_tra|nsfields|
|00006330| 2c 20 74 72 61 6e 73 5f | 74 79 70 65 2c 20 74 72 |, trans_|type, tr|
|00006340| 61 6e 73 66 69 65 6c 64 | 73 2c 20 63 6f 6e 6e 29 |ansfield|s, conn)|
|00006350| 3b 0a 09 72 65 74 75 72 | 6e 20 30 3b 09 09 2f 2a |;..retur|n 0;../*|
|00006360| 20 6f 6b 20 2a 2f 0a 7d | 0a 0a 0a 0a 2f 2a 20 53 | ok */.}|..../* S|
|00006370| 77 69 74 63 68 20 6f 6e | 20 74 72 61 6e 73 61 63 |witch on| transac|
|00006380| 74 69 6f 6e 20 74 79 70 | 65 2c 20 63 61 6c 6c 69 |tion typ|e, calli|
|00006390| 6e 67 20 68 61 6e 64 6c | 65 72 20 70 72 6f 63 65 |ng handl|er proce|
|000063a0| 64 75 72 65 20 2a 2f 0a | 73 74 61 74 69 63 20 76 |dure */.|static v|
|000063b0| 6f 69 64 0a 20 20 70 72 | 6f 63 5f 74 72 61 6e 73 |oid. pr|oc_trans|
|000063c0| 28 69 6e 74 20 6e 75 6d | 5f 74 72 61 6e 73 66 69 |(int num|_transfi|
|000063d0| 65 6c 64 73 2c 20 63 68 | 61 72 20 74 72 61 6e 73 |elds, ch|ar trans|
|000063e0| 5f 74 79 70 65 2c 20 63 | 68 61 72 20 2a 2a 74 72 |_type, c|har **tr|
|000063f0| 61 6e 73 66 69 65 6c 64 | 73 2c 0a 09 20 20 20 20 |ansfield|s,.. |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.